diff --git a/internal/installer/installer_windows.go b/internal/installer/installer_windows.go index de761c6..38cf939 100644 --- a/internal/installer/installer_windows.go +++ b/internal/installer/installer_windows.go @@ -107,9 +107,9 @@ func registerWindowsScheduledTask(exePath, listen string, allow []string) error ps := ` param( - [string]$ExePath, - [string]$Listen, - [string]$AllowJson + [string]$ExePath, + [string]$Listen, + [string]$AllowJson ) $ErrorActionPreference = 'Stop' $ServiceName = 'luxtools-client' @@ -151,14 +151,30 @@ Register-ScheduledTask -TaskName $TaskName -InputObject $task -Force | Out-Null try { Start-ScheduledTask -TaskName $TaskName | Out-Null } catch {} ` + psFile, err := os.CreateTemp("", "luxtools-client-install-*.ps1") + if err != nil { + return err + } + psPath := psFile.Name() + if _, err := psFile.WriteString(ps); err != nil { + _ = psFile.Close() + _ = os.Remove(psPath) + return err + } + if err := psFile.Close(); err != nil { + _ = os.Remove(psPath) + return err + } + defer os.Remove(psPath) + cmd := exec.Command("powershell.exe", "-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", - "-Command", ps, - exePath, - listen, - string(allowJSON), + "-File", psPath, + "-ExePath", exePath, + "-Listen", listen, + "-AllowJson", string(allowJSON), ) out, err := cmd.CombinedOutput() if err != nil {