-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
125 lines (109 loc) · 4.86 KB
/
Copy pathinstall.ps1
File metadata and controls
125 lines (109 loc) · 4.86 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# OpenGUI Installer
# Run: powershell -ExecutionPolicy Bypass -File install.ps1
param(
[switch]$Uninstall,
[switch]$StartService,
[switch]$StopService,
[string]$InstallPath = "$env:ProgramFiles\OpenGUI"
)
$ErrorActionPreference = "Stop"
$APP_NAME = "OpenGUI"
$SERVICE_EXE = "OpenGUIService.exe"
$CONTROL_EXE = "OpenGUI.Control.exe"
function Write-Step($msg) { Write-Host " [$APP_NAME] $msg" -ForegroundColor Cyan }
if ($Uninstall) {
Write-Step "Uninstalling..."
Stop-Process -Name "OpenGUIService" -Force -ErrorAction SilentlyContinue
Unregister-ScheduledTask -TaskName "OpenGUI AutoStart" -Confirm:$false -ErrorAction SilentlyContinue
if (Test-Path $InstallPath) { Remove-Item -Recurse -Force $InstallPath }
Write-Step "Uninstalled."
return
}
if ($StopService) {
Stop-Process -Name "OpenGUIService" -Force -ErrorAction SilentlyContinue
Write-Step "Service stopped."
return
}
if ($StartService) {
$svc = Join-Path $InstallPath "bin\$SERVICE_EXE"
if (Test-Path $svc) {
Start-Process -FilePath $svc -WindowStyle Hidden
Write-Step "Service started."
} else {
Write-Host "Service not found. Run install first." -ForegroundColor Red
}
return
}
# ── Install ──
Write-Host "`n=== OpenGUI Installer ===`n" -ForegroundColor Green
# 1. Copy files
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
Write-Step "Installing to $InstallPath..."
New-Item -ItemType Directory -Force -Path "$InstallPath\bin" | Out-Null
New-Item -ItemType Directory -Force -Path "$InstallPath\py" | Out-Null
Copy-Item "$scriptDir\bin\*" "$InstallPath\bin\" -Force -ErrorAction SilentlyContinue
Copy-Item "$scriptDir\py\*" "$InstallPath\py\" -Force -ErrorAction SilentlyContinue
# 2. Check dependencies
Write-Step "Checking dependencies..."
$python = Get-Command python -ErrorAction SilentlyContinue
if (-not $python) {
Write-Host " Python not found. CDP features require Python 3.10+." -ForegroundColor Yellow
Write-Host " Install from https://python.org or 'winget install Python.Python.3.12'" -ForegroundColor Yellow
} else {
Write-Host " Python: $($python.Source)" -ForegroundColor Green
# Install required packages
$pkgs = @("websockets", "pygetwindow", "pyautogui", "pyperclip", "pywin32")
foreach ($pkg in $pkgs) {
try { python -m pip install $pkg -q 2>$null } catch {}
}
Write-Host " Python packages OK" -ForegroundColor Green
}
# .NET runtime check
$dotnet = Get-Command dotnet -ErrorAction SilentlyContinue
if (-not $dotnet) {
Write-Host " .NET not found (required for Control dashboard)." -ForegroundColor Yellow
Write-Host " Install from https://dotnet.microsoft.com or 'winget install Microsoft.DotNet.SDK.9'" -ForegroundColor Yellow
} else {
Write-Host " .NET: $($dotnet.Source)" -ForegroundColor Green
}
# 3. Start service
Write-Step "Starting service..."
$svcPath = "$InstallPath\bin\$SERVICE_EXE"
if (Test-Path $svcPath) {
Stop-Process -Name "OpenGUIService" -Force -ErrorAction SilentlyContinue
Start-Sleep 1
Start-Process -FilePath $svcPath -WindowStyle Hidden
Start-Sleep 2
$running = Get-Process "OpenGUIService" -ErrorAction SilentlyContinue
if ($running) {
Write-Host " Service running (PID: $($running.Id))" -ForegroundColor Green
} else {
Write-Host " Service may need a moment to start..." -ForegroundColor Yellow
}
} else {
Write-Host " Service exe not found at $svcPath" -ForegroundColor Red
}
# 4. Auto-start via Scheduled Task
Write-Step "Configuring auto-start..."
$taskName = "OpenGUI AutoStart"
Unregister-ScheduledTask -TaskName $taskName -Confirm:$false -ErrorAction SilentlyContinue
$action = New-ScheduledTaskAction -Execute $svcPath
$trigger = New-ScheduledTaskTrigger -AtLogOn
$principal = New-ScheduledTaskPrincipal -UserId $env:USERNAME -LogonType Interactive
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -StartWhenAvailable -RestartCount 5 -RestartInterval (New-TimeSpan -Minutes 1)
Register-ScheduledTask -TaskName $taskName -Action $action -Trigger $trigger -Principal $principal -Settings $settings -Force | Out-Null
Write-Host " Auto-start configured" -ForegroundColor Green
# 5. PATH
Write-Step "Environment..."
$currentPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($currentPath -notlike "*$InstallPath\bin*") {
[Environment]::SetEnvironmentVariable("Path", "$currentPath;$InstallPath\bin", "User")
Write-Host " Added to PATH" -ForegroundColor Green
}
Write-Host "`n=== Installation Complete ===" -ForegroundColor Green
Write-Host " Service: $svcPath"
Write-Host " Python bridge: $InstallPath\py\"
Write-Host " Auto-start: Enabled (Scheduled Task)"
Write-Host "`n Usage:"
Write-Host " python -c ""from reliable_bridge import status; print(status())"""
Write-Host " python -c ""from cdp_bridge import cdp_type; cdp_type('HI')"""