implement check for admin (#818)

check if script is running as admin or not and if not then it attempt to relaunch with admin privilege.
This commit is contained in:
Padsala Tushal
2023-06-15 02:49:26 +05:30
committed by GitHub
parent dac753d806
commit ba4dba5f87
2 changed files with 16 additions and 2 deletions

View File

@ -17,3 +17,10 @@ $sync.PSScriptRoot = $PSScriptRoot
$sync.version = "#{replaceme}"
$sync.configs = @{}
$sync.ProcessRunning = $false
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Output "Winutil needs to be ran as Administrator. Attempting to relaunch."
Start-Process -Verb runas -FilePath powershell.exe -ArgumentList "iwr -useb https://christitus.com/win | iex"
break
}