fix(windows): downgrade Elevated Privileges error to warn-once (for ssh)

This commit is contained in:
AJ ONeal
2023-11-11 23:06:32 -07:00
parent e41e27b442
commit 2046371f62
2 changed files with 22 additions and 12 deletions
-12
View File
@@ -3,18 +3,6 @@
$OriginalPath = $Env:Path
function Confirm-IsElevated {
$id = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$p = New-Object System.Security.Principal.WindowsPrincipal($id)
if ($p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator))
{ Write-Output $true }
else
{ Write-Output $false }
}
if (Confirm-IsElevated)
{ throw "Webi MUST NOT be run with elevated privileges. Please run again as a normal user, NOT as administrator." }
# this allows us to call ps1 files, which allows us to have spaces in filenames
# ('powershell "$Env:USERPROFILE\test.ps1" foo' will fail if it has a space in
# the path but '& "$Env:USERPROFILE\test.ps1" foo' will work even with a space)
+22
View File
@@ -24,6 +24,28 @@ $TCmd = "${Esc}[2m${Esc}[35m"
$TDim = "${Esc}[2m"
$TReset = "${Esc}[0m"
$OriginalPath = $Env:Path
$IsWebiParent = -Not (Test-Path Env:IsWebiChild)
$Env:IsWebiChild = $true
function Confirm-IsElevated {
$id = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$p = New-Object System.Security.Principal.WindowsPrincipal($id)
if ($p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator))
{ Write-Output $true }
else
{ Write-Output $false }
}
IF (Confirm-IsElevated) {
IF ($IsWebiParent) {
Write-Host ""
Write-Host "Running Webi with elevated privileges is unsupported." -ForegroundColor Magenta -BackgroundColor black
Write-Host "Please run Webi as a normal user, NOT as administrator." -ForegroundColor Magenta -BackgroundColor black
Write-Host ""
}
}
function Invoke-DownloadUrl {
Param (
[string]$URL,