fix(windows): run daemon without console window - #1689
Open
sean2077 wants to merge 1 commit into
Open
Conversation
Use wscript.exe with a windowless VBScript launcher for Task Scheduler startup and restart loops. Clean up legacy PowerShell launchers and orphaned daemon instances during stop operations.\n\nAlso keep the current Windows source build compilable by excluding the non-Windows CheckLinger stub on Windows and removing an unused Windows-only import.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace the Windows Scheduled Task PowerShell launcher with a
wscript.exe //B //NoLogoVBScript launcher. The launcher starts the console-subsystem binary with window style0, so daemon startup and restart no longer leave a PowerShell console visible.It preserves the configured log and environment variables, retry behavior, and working directory; removes legacy
.ps1launchers on reinstall or uninstall; and stops launcher children plus a verified lock-file process as a safe orphan fallback. This PR also includes the two minimal Windows source-build fixes required for the currentmainbranch to compile on Windows.Type of change
Testing
go test ./daemon -run '^(TestBuildWindowsTaskScript|TestBuildWindowsTaskScript_DropsInvalidEnvName|TestBuildWindowsTaskScript_DropsEmptyValue|TestWindowsTaskActionUsesWindowlessScriptHost|TestWindowsTaskCreateUsesLimitedInteractivePrincipal|TestWindowsTaskMatchesActionRequiresExactAction|TestPowerShellLiteralEscapesSingleQuotes|TestVBScriptLiteralEscapesDoubleQuotes|TestSchtasksInstallRemovesLegacyPowerShellLauncher|TestStopWindowsTaskKillsLauncherChildrenAndLockedInstance)$' -count=1go test ./agent/pi -run '^$' -count=1go build -tags no_web ./...wscript.exe //B //NoLogo ...cc-connect-daemon.vbs, with bothwscript.exeandcc-connect.exereportingMainWindowHandle = 0. Feishu reachedplatform readyandengine started.go build ./...requires generatedweb/distassets, which this clean local worktree does not contain; CI builds those assets before its normal build step.go test ./daemon -count=1still fails the existing Windows-only precondition inTestSchtasksInstall_TightensExistingScriptFrom0644because this filesystem reports a seeded mode of0666, not0644.go test -tags no_web ./...has existing Windows-only failures in path, shell, PTY, and file-mode assumptions outside this change.Automated tests added in this PR
TestWindowsTaskActionUsesWindowlessScriptHostindaemon/windows_test.go- verifies the scheduled task useswscript.exe //B //NoLogoinstead of PowerShell.TestVBScriptLiteralEscapesDoubleQuotesindaemon/windows_test.go- verifies safe VBScript string generation.TestSchtasksInstallRemovesLegacyPowerShellLauncherindaemon/windows_test.go- verifies upgrade cleanup of the old PowerShell launcher.TestStopWindowsTaskKillsLauncherChildrenAndLockedInstanceindaemon/windows_test.go- verifies launcher-child and verified lock-PID cleanup are emitted.For bug fixes only - regression test
TestWindowsTaskActionUsesWindowlessScriptHostCritical User Journeys (CUJ) impact
Manual / user-visible behavior change
On Windows,
cc-connect daemon installandcc-connect daemon restartnow run the service with no visible PowerShell console window. Existing installations migrate away from the old PowerShell launcher on reinstall.Checklist
go build -tags no_web ./...passescore/go test ./...passes locally (see Windows-only baseline failures above)Related