mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-07-09 14:43:52 -05:00
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:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user