mirror of
https://github.com/webinstall/webi-installers.git
synced 2026-08-19 03:56:16 +00:00
fix(windows): downgrade Elevated Privileges error to warn-once (for ssh)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user