Skip to content

Fix BCU-console hanging on Console.ReadKey() after showing help - #966

Merged
Klocman merged 2 commits into
BCUninstaller:masterfrom
hazeliscoding:fix-console-help-readkey
Aug 11, 2026
Merged

Klocman merged 2 commits into
BCUninstaller:masterfrom
hazeliscoding:fix-console-help-readkey

Conversation

@hazeliscoding

Copy link
Copy Markdown
Collaborator

Fixes #956

BCU-console help / /? called Console.ReadKey() after printing help, which blocked interactive shells and threw InvalidOperationException when console input was redirected (pipes, CI, Task Scheduler).

This removes the Console.ReadKey() call so help prints and exits 0 immediately.

@hazeliscoding hazeliscoding changed the title Fix BCU-console hanging on Console.ReadKey() after showing help (#956) Fix BCU-console hanging on Console.ReadKey() after showing help Jul 27, 2026
@Klocman

Klocman commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

This is done deliberately since the target audience are Windows users that are likely to double click the exe and wonder what happened. As far as I could see there was no way to detect if the app was ran in a shell or standalone.

What exactly is the use of running the help command in a script?

@hazeliscoding

hazeliscoding commented Aug 5, 2026 •

Copy link
Copy Markdown
Collaborator Author

This is done deliberately since the target audience are Windows users that are likely to double click the exe and wonder what happened. As far as I could see there was no way to detect if the app was ran in a shell or standalone.

What exactly is the use of running the help command in a script?

I can update the PR to skip the pause when input is redirected and only pause when the app owns the console (GetConsoleProcessList() == 1). That keeps the window open for double-click users without adding an extra prompt for shell users.

@Klocman

Klocman commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

I can update the PR to skip the pause when input is redirected and only pause when the app owns the console (GetConsoleProcessList() == 1). That keeps the window open for double-click users without adding an extra prompt for shell users.

This would work, yeah.

Replace the unconditional Console.ReadKey() after showing help with a
guarded pause: skip it when input is redirected (pipe, file, Task
Scheduler, CI - where ReadKey throws InvalidOperationException) and only
pause when this process owns its console (a double-click), so shell users
don't get an unwanted prompt while double-click users still get the
window held open.

Fixes BCUninstaller#956
@Klocman
Klocman merged commit 608321d into BCUninstaller:master Aug 11, 2026
1 check passed
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.

BCU-console: help / /? calls Console.ReadKey() and hangs/throws in non-interactive shells

3 participants