24 lines
554 B
Go
24 lines
554 B
Go
package startup
|
|||
|
|
|
||
|
|
import (
|
||
|
|
"fmt"
|
||
|
|
"strings"
|
||
|
|
)
|
||
|
|
|
||
|
|
const ensureArg = "-ensure"
|
||
|
|
|
||
|
|
// ensureTaskTR is the schtasks /TR task action: "<exe> -ensure".
|
||
|
|
func ensureTaskTR(exe string) string {
|
||
|
|
return strings.Trim(exe, `"`) + " " + ensureArg
|
||
|
|
}
|
||
|
|
|
||
|
|
// schtasksCreateCmdLine is the full Windows command line for schtasks /Create.
|
||
|
|
// ponytail: SysProcAttr.CmdLine bypasses Go's /TR quoting bugs.
|
||
|
|
func schtasksCreateCmdLine(taskName, tr string) string {
|
||
|
|
return fmt.Sprintf(
|
||
|
|
`schtasks.exe /Create /TN %s /SC MINUTE /MO 15 /RL LIMITED /F /TR "%s"`,
|
||
|
|
taskName,
|
||
|
|
tr,
|
||
|
|
)
|
||
|
|
}
|