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
Starting PowerShell/pwsh with '-WindowStyle hidden' should not flash console window. #249
Comments
As it's been discussed in the thread you linked, any and all Console Subsystem applications get a console window it they aren't already attached to one, full stop. They need conhost.exe to be able to service console API calls. What you'd be asking for Windows to not create console windows for any console applications by default, and that's a feature that we're not about to add. There really isn't a way that a parent process that's calling a commandline could know if that particular commandline intends to be hidden or not. Nor is there a way for a commandline application to manifest itself to say "I would like to be hidden by default". A caller could pass the It's also kind of a pain to have a single pwsh.exe that is a Windows subsystem application that potentially re-attaches to the console it was started from (if Having two executables (pwsh.exe and pwshw.exe) is really the best way to get that effect for the time being. I'm going to close this issue for now, and defer to the discussion in the powershell thread. Feel free to reopen if there's a concrete and actionable suggestion that the console team could reasonably implement. |
Thank you @zadjii-msft for taking the time to write this thorough answer, really appreciated! |
Do we not have the technology to input a command into a program to cause it to be hidden? Perhaps for example "-hidden"? |
The initialization code in kernelbase.dll is what allocates the console. This is part of process setup, which necessarily precedes calling the application entry point and parsing the command line. There are 3 creation flags that affect this: It might be useful to add a creation flag that's similar to |
And I consider this a high priority feature request because the .vbs script that everyone is using to make powershell work as expected MUST be a huge security risk that defeats part of the purpose of powershell! |
as a workaround until the feature is implemented (I hope it does) it's possible to wrap the script in a .NET executable using MScholtes PS2EXE project: https://github.com/MScholtes/PS2EXE |
I would have expected this very issue to be the place to track the request for a |
Your Windows build number: (Type
ver
at a Windows Command Prompt)Microsoft Windows [Version 10.0.17134.228]
What you're doing and what's happening: (Copy & paste specific commands and their output, or include screen shots)
I am cross-posting this issue from the PowerShell/PowerShell repository.
People are reporting that the console does not respect the
-WindowStyle hidden
flag. This is unexpected to them.[win]+R
then typepwsh -WindowStyle hidden -command 'start-sleep 10'
[win]+R
then typepowershell -WindowStyle hidden -command 'start-sleep 10'
Create a scheduled task that reflects one of the command above.
What happens: a pwsh-window is briefly displayed before it is hidden.
When starting PowerShell/pwsh with the
-WindowStyle hidden
parameter, no console window should be displayed.It would be great if somehow before connecting a console window to the PowerShell/pwsh process, this
-WindowStyle hidden
flag gets checked. (Yes, I read the awesome blog series by @bitcrazed 👍)The text was updated successfully, but these errors were encountered: