Skip to content

Commit 7a4a350

Browse files
committed
fix: update install script on windows
1 parent 0dd318f commit 7a4a350

3 files changed

Lines changed: 53 additions & 23 deletions

File tree

internal/deps/deps.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,14 @@ func (m *Manager) downloadLibraryToDir(ctx context.Context, lib Library, libsDir
786786
}
787787
}
788788

789+
// On Windows, remove the Zone.Identifier alternate data stream that marks
790+
// files as "downloaded from the internet". Without this, SmartScreen or
791+
// other security prompts may appear when the binary is executed from a
792+
// non-interactive session (e.g., scheduled task), silently blocking the process.
793+
if platform.IsWindows() {
794+
_ = os.Remove(destPath + ":Zone.Identifier")
795+
}
796+
789797
// Create versioned symlinks for .so files (e.g., libcuda.so.1 -> libcuda.so)
790798
if isSharedLibrary(lib.Name) && !platform.IsWindows() {
791799
if err := createVersionedSymlinks(destPath, lib.Name); err != nil {

scripts/install.ps1

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -196,40 +196,62 @@ function Register-Agent {
196196

197197
function Setup-WindowsService {
198198
param([string]$BinaryPath)
199-
199+
200200
Write-Info ""
201201
Write-Info "Setting up Windows scheduled task for auto-start..."
202-
202+
203203
# Remove existing task if exists
204204
$existingTask = Get-ScheduledTask -TaskName $TASK_NAME -ErrorAction SilentlyContinue
205205
if ($existingTask) {
206206
Write-Info "Removing existing scheduled task..."
207207
Unregister-ScheduledTask -TaskName $TASK_NAME -Confirm:$false
208208
}
209-
209+
210+
# Capture the registering user's home directory so the task can find config/cache
211+
# even when running without an interactive session.
212+
$userHome = $env:USERPROFILE
213+
$configDir = Join-Path $userHome ".gpugo\config"
214+
$stateDir = Join-Path $userHome ".gpugo\state"
215+
$cacheDir = Join-Path $userHome ".gpugo\cache"
216+
217+
# Pass explicit paths so the agent resolves files under the registering user's
218+
# profile regardless of which account the scheduled task runs as.
219+
$agentArgs = "agent start --config-dir `"$configDir`" --state-dir `"$stateDir`""
220+
210221
# Create scheduled task for auto-start at system startup
211-
$action = New-ScheduledTaskAction -Execute $BinaryPath -Argument "agent start"
212-
222+
$action = New-ScheduledTaskAction -Execute $BinaryPath -Argument $agentArgs
223+
224+
# Environment variable so DownloadOrFindAccelerator and deps manager
225+
# locate cached libraries in the registering user's cache directory.
226+
$envSetting = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -StartWhenAvailable -RestartCount 3 -RestartInterval (New-TimeSpan -Minutes 1)
227+
213228
# Trigger at system startup
214229
$trigger = New-ScheduledTaskTrigger -AtStartup
215-
216-
# Run as SYSTEM with highest privileges
217-
$principal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -LogonType ServiceAccount -RunLevel Highest
218-
219-
# Settings
220-
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -StartWhenAvailable -RestartCount 3 -RestartInterval (New-TimeSpan -Minutes 1)
221-
230+
231+
# Run as the current (registering) user via S4U logon so the task can access
232+
# user-profile paths without requiring the user to be interactively logged in.
233+
# S4U does not store a password and still uses the user's profile environment.
234+
$currentUser = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name
235+
$principal = New-ScheduledTaskPrincipal -UserId $currentUser -LogonType S4U -RunLevel Highest
236+
222237
# Register the task
223-
Register-ScheduledTask -TaskName $TASK_NAME -Action $action -Trigger $trigger -Principal $principal -Settings $settings -Description "GPU Go Agent - GPU Sharing Service" | Out-Null
224-
238+
Register-ScheduledTask -TaskName $TASK_NAME -Action $action -Trigger $trigger -Principal $principal -Settings $envSetting -Description "GPU Go Agent - GPU Sharing Service" | Out-Null
239+
240+
# Persist GGO_CACHE_DIR as a machine-level environment variable so the
241+
# scheduled task can locate cached libraries when running without an
242+
# interactive session. Machine-level env vars are inherited by all processes.
243+
[Environment]::SetEnvironmentVariable("GGO_CACHE_DIR", $cacheDir, "Machine")
244+
$env:GGO_CACHE_DIR = $cacheDir
245+
225246
Write-Info "Scheduled task '$TASK_NAME' created successfully!"
226-
247+
227248
# Start the task immediately
228249
Write-Info "Starting GPU Go agent..."
229250
Start-ScheduledTask -TaskName $TASK_NAME
230-
231-
Start-Sleep -Seconds 2
232-
251+
252+
# Allow the agent a few seconds to initialise (library load + API handshake)
253+
Start-Sleep -Seconds 5
254+
233255
$taskInfo = Get-ScheduledTask -TaskName $TASK_NAME
234256
if ($taskInfo.State -eq "Running") {
235257
Write-Info "Agent started successfully!"
@@ -327,7 +349,7 @@ function Install-Ggo {
327349
# Add to PATH (system-wide if admin, user otherwise)
328350
if ($AddToPath) {
329351
if (Test-Administrator) {
330-
Add-ToSystemPath -Directory $InstallDir
352+
$null = Add-ToSystemPath -Directory $InstallDir
331353
} else {
332354
$currentPath = [Environment]::GetEnvironmentVariable("PATH", "User")
333355
if ($currentPath -notlike "*$InstallDir*") {
@@ -360,10 +382,10 @@ function Install-Ggo {
360382
Write-Host "==========================================" -ForegroundColor Yellow
361383

362384
# Register agent
363-
Register-Agent -BinaryPath $destPath -AgentToken $Token
364-
385+
$null = Register-Agent -BinaryPath $destPath -AgentToken $Token
386+
365387
# Setup Windows service
366-
Setup-WindowsService -BinaryPath $destPath
388+
$null = Setup-WindowsService -BinaryPath $destPath
367389

368390
Write-Host ""
369391
Write-Host "==========================================" -ForegroundColor Green

vscode-extension/src/cli/downloader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ export class CLIDownloader {
210210

211211
// 2. Check system PATH
212212
try {
213-
await exec('ggo --version');
213+
await exec('ggo version');
214214
Logger.log('CLI found in system PATH');
215215
return 'ggo';
216216
} catch {

0 commit comments

Comments
 (0)