Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile launcher Windows as a GUI binary to avoid cmd window prompts #1007

Merged
merged 3 commits into from
Feb 2, 2023

Conversation

seejdev
Copy link
Contributor

@seejdev seejdev commented Jan 30, 2023

Fixed #943

This PR includes the change to enable Windows launcher to be built as a GUI binary instead of a console binary. We originally reverted this code but it appears this doesn't break autoupdate like we originally feared.

The second change updates the CI check to ignore any output and just verify that launcher --version ran successfully. This better matches the check that the autoupdate code performs on binaries.

Behavior changes

Windows CMD will wait for console binaries and return their output, whereas GUI binaries are not waited for and no output is returned:

launcher_console.exe --version
{"caller":"main.go:30","msg":"Launcher starting up","revision":"7e862bc58116421ecb154a0ef73ec9f329f42a7e","severity":"info","ts":"2023-02-01T20:55:15.3027199Z","version":"0.13.2-18-g7e862bc-dirty"}
launcher - version 0.13.2-18-g7e862bc-dirty
  branch:       main
  revision:     7e862bc58116421ecb154a0ef73ec9f329f42a7e
  build date:   2023-01-31
  build user:   you
  go version:   go1.19.2

launcher_gui.exe --version

To get the output of a GUI binary, we can invoke it via start, wait for the output, and redirect it.

start /B /wait launcher_gui.exe --version >> output.txt

PowerShell will automatically apply Out-String to a command's output before sending it to the input of another cmdlet, like findstr:

PS > launcher_gui.exe --version | Out-String
launcher - version 0.13.2-19-g8631e5c-dirty
  branch:       main
  revision:     8631e5c970f33bb0f859fb9819a6873c33481925
  build date:   2023-02-01
  build user:   CJ Barrett (CJHP\cjbar)
  go version:   go1.19.2
PS > launcher_gui.exe --version
PS > launcher_gui.exe --version | findstr "launcher - version"
launcher - version 0.13.2-19-g8631e5c-dirty
  build date:   2023-02-01
  go version:   go1.19.2

Testing Notes

I was unable to reproduce any bad autoupdate behavior when injecting a GUI binary into the tests for the autoupdate checkExecutable code which calls launcher --version:

I verified replacing my existing launcher installation updates dir binaries with GUI binaries still launches successfully.

Some helpful references:

https://stackoverflow.com/questions/54536/win32-gui-app-that-writes-usage-text-to-stdout-when-invoked-as-app-exe-help
https://superuser.com/questions/1198821/how-do-i-read-the-console-output-of-a-windows-gui-application
https://www.sapien.com/blog/2014/12/15/display-output-in-a-gui-application-copy/
https://devblogs.microsoft.com/oldnewthing/20090101-00/?p=19643

@seejdev seejdev force-pushed the issue943 branch 3 times, most recently from b7673ed to bb79e70 Compare February 1, 2023 15:49
@seejdev seejdev changed the title WIP Windows cmd prompt stays open Compile launcher Windows as a GUI binary to avoid cmd window prompts Feb 2, 2023
@seejdev seejdev marked this pull request as ready for review February 2, 2023 12:46
Copy link
Contributor

@directionless directionless left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice write up in the PR. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

On fresh install of windows, with launcher desktop enabled, a cmd prompt stays open
4 participants