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)) { 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." Write-Output "Winutil needs to be run as Administrator. Attempting to relaunch."
$wtInstalled = Get-Command wt.exe -ErrorAction SilentlyContinue $script = if (Test-Path "$PSScriptRoot\winutil.ps1") {
$pwshInstalled = Get-Command pwsh -ErrorAction SilentlyContinue "$PSScriptRoot\winutil.ps1"
if ($pwshInstalled) {
$powershellcmd = "pwsh"
} else { } else {
$powershellcmd = "powershell" "irm christitus.com/win | iex"
}
$powershellcmd = if (Get-Command pwsh -ErrorAction SilentlyContinue) {
"pwsh"
} else {
"powershell"
} }
if ($wtInstalled) { $processCmd = if (Get-Command wt.exe -ErrorAction SilentlyContinue) {
Start-Process wt.exe -ArgumentList "$powershellcmd -ExecutionPolicy Bypass -NoProfile -File $PSScriptRoot\winutil.ps1 -Run" -Verb RunAs "wt"
} else { } 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 break
} }

View File

@ -12,6 +12,27 @@
Run in Admin Powershell > ./windev.ps1 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 to fetch the latest release tag from the GitHub API
function Get-LatestRelease { function Get-LatestRelease {
try { try {