feat(scanner): validate elevated live automation
This commit is contained in:
@@ -9,8 +9,17 @@ $ErrorActionPreference = "Stop"
|
||||
|
||||
try {
|
||||
$project = (Resolve-Path -LiteralPath $ProjectRoot).Path
|
||||
$logDir = Join-Path $project "outputs\admin-start"
|
||||
New-Item -ItemType Directory -Force -Path $logDir | Out-Null
|
||||
$logPath = Join-Path $logDir "admin-dev.log"
|
||||
try {
|
||||
Start-Transcript -Path $logPath -Append | Out-Null
|
||||
} catch {
|
||||
Write-Host "WARNUNG: Admin-Start-Log konnte nicht geschrieben werden: $($_.Exception.Message)" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
Write-Host "Projekt: $project"
|
||||
Write-Host "Admin-Log: $logPath"
|
||||
|
||||
# A UAC-elevated process gets its environment rebuilt fresh from the
|
||||
# registry; it does NOT inherit PATH edits that only exist in the calling
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
param(
|
||||
[string]$ProjectRoot = (Resolve-Path -LiteralPath (Join-Path $PSScriptRoot "..")).Path
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
function Quote-ProcessArgument([string]$Value) {
|
||||
return '"' + $Value.Replace('"', '\"') + '"'
|
||||
}
|
||||
|
||||
try {
|
||||
$project = (Resolve-Path -LiteralPath $ProjectRoot).Path
|
||||
$script = Join-Path $PSScriptRoot "dev-admin-start.ps1"
|
||||
$powershellExe = Join-Path $env:SystemRoot "System32\WindowsPowerShell\v1.0\powershell.exe"
|
||||
$arguments = @(
|
||||
"-NoProfile",
|
||||
"-ExecutionPolicy Bypass",
|
||||
"-NoExit",
|
||||
"-File $(Quote-ProcessArgument $script)",
|
||||
"-ProjectRoot $(Quote-ProcessArgument $project)"
|
||||
) -join " "
|
||||
|
||||
Start-Process -FilePath $powershellExe -ArgumentList $arguments -WorkingDirectory $project -Verb RunAs -WindowStyle Normal -ErrorAction Stop
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "UAC-Abfrage gestartet. Bitte bestaetigen - danach oeffnet sich ein neues Administrator-Fenster mit npm run dev." -ForegroundColor Green
|
||||
Write-Host "Dieses Fenster kann geschlossen werden; das eigentliche Programm laeuft im neuen Administrator-Fenster."
|
||||
} catch {
|
||||
Write-Host ""
|
||||
Write-Host "Admin-Start fehlgeschlagen oder UAC-Abfrage abgelehnt:" -ForegroundColor Red
|
||||
Write-Host $_.Exception.Message -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
Reference in New Issue
Block a user