This commit is contained in:
MyDrift 2024-08-21 23:52:27 +02:00
parent a6d4d47a88
commit ede8733b9b
2 changed files with 33 additions and 8 deletions

View File

@ -47,19 +47,23 @@ $sync.ProcessRunning = $false
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Output "Winutil needs to be run as Administrator. Attempting to relaunch."
$wtInstalled = Get-Command wt.exe -ErrorAction SilentlyContinue
$pwshInstalled = Get-Command pwsh -ErrorAction SilentlyContinue
if ($pwshInstalled) {
$powershellcmd = "pwsh"
$script = if (Test-Path "$PSScriptRoot\winutil.ps1") {
"$PSScriptRoot\winutil.ps1"
} else {
$powershellcmd = "powershell"
"irm christitus.com/win | iex"
}
$powershellcmd = if (Get-Command pwsh -ErrorAction SilentlyContinue) {
"pwsh"
} else {
"powershell"
}
if ($wtInstalled) {
Start-Process wt.exe -ArgumentList "$powershellcmd -ExecutionPolicy Bypass -NoProfile -File $PSScriptRoot\winutil.ps1 -Run" -Verb RunAs
$processCmd = if (Get-Command wt.exe -ErrorAction SilentlyContinue) {
"wt"
} else {
Start-Process $powershellcmd -ArgumentList "-ExecutionPolicy Bypass -NoProfile -File $PSScriptRoot\\winutil.ps1 -Run" -Verb RunAs
$powershellcmd
}
Start-Process $processCmd -ArgumentList "$powershellcmd -ExecutionPolicy Bypass -NoProfile -Command $script" -Verb RunAs
break
}

View File

@ -12,6 +12,27 @@
Run in Admin Powershell > ./windev.ps1
#>
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Output "Winutil needs to be run as Administrator. Attempting to relaunch."
$script = "irm christitus.com/windev | iex"
$powershellcmd = if (Get-Command pwsh -ErrorAction SilentlyContinue) {
"pwsh"
} else {
"powershell"
}
$processCmd = if (Get-Command wt.exe -ErrorAction SilentlyContinue) {
"wt"
} else {
$powershellcmd
}
Start-Process $processCmd -ArgumentList "$powershellcmd -ExecutionPolicy Bypass -NoProfile -Command $script" -Verb RunAs
break
}
# Function to fetch the latest release tag from the GitHub API
function Get-LatestRelease {
try {