From cfdf24284dbb2b9703eaf7377ef013585b614d46 Mon Sep 17 00:00:00 2001 From: dinger1986 Date: Mon, 29 Aug 2022 15:01:55 +0100 Subject: [PATCH] Update WindowsAgentAIOInstall.ps1 --- WindowsAgentAIOInstall.ps1 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/WindowsAgentAIOInstall.ps1 b/WindowsAgentAIOInstall.ps1 index d21a3bb..174081e 100644 --- a/WindowsAgentAIOInstall.ps1 +++ b/WindowsAgentAIOInstall.ps1 @@ -1,5 +1,11 @@ $ErrorActionPreference= 'silentlycontinue' -#Requires -RunAsAdministrator +#Run as administrator and stays in the current directory +if (-Not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { + if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) { + Start-Process PowerShell -Verb RunAs -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command `"cd '$pwd'; & '$PSCommandPath';`""; + Exit; + } +} # Replace wanipreg and keyreg with the relevant info for your install. IE wanipreg becomes your rustdesk server IP or DNS and keyreg becomes your public key. $rustdesk_url = 'https://github.com/rustdesk/rustdesk/releases/latest'