mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-07-09 06:33:51 -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
|
||||
}
|
||||
|
11
winutil.ps1
11
winutil.ps1
@ -10,7 +10,7 @@
|
||||
Author : Chris Titus @christitustech
|
||||
Runspace Author: @DeveloperDurp
|
||||
GitHub : https://github.com/ChrisTitusTech
|
||||
Version : 23.05.27
|
||||
Version : 23.06.02
|
||||
#>
|
||||
|
||||
Start-Transcript $ENV:TEMP\Winutil.log -Append
|
||||
@ -21,9 +21,16 @@ Add-Type -AssemblyName System.Windows.Forms
|
||||
# variable to sync between runspaces
|
||||
$sync = [Hashtable]::Synchronized(@{})
|
||||
$sync.PSScriptRoot = $PSScriptRoot
|
||||
$sync.version = "23.05.27"
|
||||
$sync.version = "23.06.02"
|
||||
$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
|
||||
}
|
||||
Function Get-WinUtilCheckBoxes {
|
||||
|
||||
<#
|
||||
|
Reference in New Issue
Block a user