fix: on Windows don't allocate console if not opened inside one (#10726)
This change allows Syncthing to be launched from Explorer without showing a console window, while preserving the existing command-line behavior. Previously, launching syncthing.exe from Explorer would always allocate a console window, which could only be hidden later by using `--no-console`. It was not possible to avoid console allocation entirely without introducing other issues. On Windows 24H2 and later a new application manifest allows us to achieve it. See [console allocation policy](https://learn.microsoft.com/en-us/windows/console/console-allocation-policy) This manifest is built into a syso-file by `goversioninfo`, which is already used to generate Windows resource files consumed by the Go compiler. **Note1:** On Windows 24H2 and later, no console is allocated when Syncthing is launched from Explorer, even if `--no-console` is set to `False`. It can still be used as a CLI tool as usual if you call it from console. **Note2:** The content of the manifest file may not be formatted. Even a `newline` would break it. ### Testing Tested on Windows 11 25H2: No console visible from explorer. CLI works as usual. Ref #8046, ref #10633, ref #10481, ref #10600 Signed-off-by: Elias <1elias.bauer@gmail.com> Co-authored-by: Elias <1elias.bauer@gmail.com>
This commit is contained in:
@@ -7,5 +7,5 @@
|
||||
package main
|
||||
|
||||
type buildSpecificOptions struct {
|
||||
HideConsole bool `name:"no-console" help:"Hide console window" env:"STHIDECONSOLE"`
|
||||
HideConsole bool `name:"no-console" help:"Hide console window (Always enabled on Windows 11 24H2 and later)" env:"STHIDECONSOLE"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user