-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdev-admin.ps1
More file actions
48 lines (42 loc) · 2.15 KB
/
Copy pathdev-admin.ps1
File metadata and controls
48 lines (42 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# dev-admin.ps1 - Launch xstat dev environment as Administrator
# Run this once; it will UAC-prompt and restart everything elevated.
$appDir = Join-Path $PSScriptRoot "src\app"
$node = (Get-Command node -ErrorAction Stop).Source
$cli = Join-Path $appDir "node_modules\electron-vite\dist\cli.mjs"
if (-not (Test-Path $cli)) {
Write-Error "electron-vite not found. Run npm install inside src\app first."
exit 1
}
# Check if already elevated
$id = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$principal = [System.Security.Principal.WindowsPrincipal]$id
$isAdmin = $principal.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)
if ($isAdmin) {
# ---- PawnIO: install if missing ----
# PawnIO is a signed kernel driver (HVCI-compatible) that replaces WinRing0.
# LHM 0.9.6+ uses it automatically once the service is running.
$pawnioSvc = Get-Service -Name "PawnIO" -ErrorAction SilentlyContinue
if (-not $pawnioSvc) {
Write-Host "PawnIO kernel driver not found - installing via winget..." -ForegroundColor Cyan
winget install namazso.PawnIO --silent --accept-package-agreements --accept-source-agreements
if ($LASTEXITCODE -eq 0) {
Write-Host "PawnIO installed. AMD CPU/GPU sensor data now available." -ForegroundColor Green
} else {
Write-Warning "PawnIO install returned exit code $LASTEXITCODE - sensor data may be limited."
}
} else {
Write-Host "PawnIO driver already installed (status: $($pawnioSvc.Status))." -ForegroundColor Green
}
# ---- Kill any stale processes then launch ----
Stop-Process -Name "electron","XStat.Service" -Force -ErrorAction SilentlyContinue
Start-Sleep -Milliseconds 500
Write-Host "Starting dev server..." -ForegroundColor Green
Set-Location $appDir
& $node $cli dev
} else {
Write-Host "Relaunching as Administrator (UAC prompt)..." -ForegroundColor Yellow
# Re-invoke this same script elevated - it will handle PawnIO and then launch.
Start-Process powershell `
-ArgumentList "-NoProfile","-ExecutionPolicy","Bypass","-File","`"$PSCommandPath`"" `
-Verb RunAs
}