fix windows install script
This commit is contained in:
@@ -107,9 +107,9 @@ func registerWindowsScheduledTask(exePath, listen string, allow []string) error
|
|||||||
|
|
||||||
ps := `
|
ps := `
|
||||||
param(
|
param(
|
||||||
[string]$ExePath,
|
[string]$ExePath,
|
||||||
[string]$Listen,
|
[string]$Listen,
|
||||||
[string]$AllowJson
|
[string]$AllowJson
|
||||||
)
|
)
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
$ServiceName = 'luxtools-client'
|
$ServiceName = 'luxtools-client'
|
||||||
@@ -151,14 +151,30 @@ Register-ScheduledTask -TaskName $TaskName -InputObject $task -Force | Out-Null
|
|||||||
try { Start-ScheduledTask -TaskName $TaskName | Out-Null } catch {}
|
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",
|
cmd := exec.Command("powershell.exe",
|
||||||
"-NoProfile",
|
"-NoProfile",
|
||||||
"-NonInteractive",
|
"-NonInteractive",
|
||||||
"-ExecutionPolicy", "Bypass",
|
"-ExecutionPolicy", "Bypass",
|
||||||
"-Command", ps,
|
"-File", psPath,
|
||||||
exePath,
|
"-ExePath", exePath,
|
||||||
listen,
|
"-Listen", listen,
|
||||||
string(allowJSON),
|
"-AllowJson", string(allowJSON),
|
||||||
)
|
)
|
||||||
out, err := cmd.CombinedOutput()
|
out, err := cmd.CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user