winutil/scripts/start.ps1
Padsala Tushal ba4dba5f87
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.
2023-06-14 16:19:26 -05:00

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
}