mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-11-16 23:55:50 -06:00
ba4dba5f87
check if script is running as admin or not and if not then it attempt to relaunch with admin privilege.
27 lines
860 B
PowerShell
27 lines
860 B
PowerShell
<#
|
|
.NOTES
|
|
Author : Chris Titus @christitustech
|
|
Runspace Author: @DeveloperDurp
|
|
GitHub : https://github.com/ChrisTitusTech
|
|
Version : #{replaceme}
|
|
#>
|
|
|
|
Start-Transcript $ENV:TEMP\Winutil.log -Append
|
|
|
|
#Load DLLs
|
|
Add-Type -AssemblyName System.Windows.Forms
|
|
|
|
# variable to sync between runspaces
|
|
$sync = [Hashtable]::Synchronized(@{})
|
|
$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
|
|
}
|