Powershell -WindowStyle Hidden still shows a window briefly
See original GitHub issueSteps to reproduce
In Windows Run dialog type this:
PowerShell.exe -WindowStyle Hidden -Command ping www.microsoft.com
Expected behavior
There should be no window, right now you can’t start powershell without window flashing, making it rather useless e.g. for scheduled tasks.
Note I think this is intended behavior, but it’s confusing and new option is probably required. If you search how to run a powershell in scheduled task, the go-to workaround is to do a vbs script of all things! Such as:
Dim shell,command
command = "powershell.exe -nologo -File D:\myscript.ps1"
Set shell = CreateObject("WScript.Shell")
shell.Run command,0
This is not a good thing, powershell needs this feature in the shell itself, scheduled tasks are important feature and having a window flash on scheduled task is a really bad experience.
Actual behavior
It flashes the powershell window briefly.
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.14393.693
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.693
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Issue Analytics
- State:
- Created 7 years ago
- Reactions:123
- Comments:114 (26 by maintainers)
Top Results From Across the Web
Powershell - windowstyle hidden
By using -WindowStyle Hidden you're asking to run the script hidden, i.e. invisibly (though a console window still briefly appears, ...
Read more >Powershell: -windowstyle hidden is just a lie
The GitHub explains why - the console application launches first and displays the window before processing the WindowStyle parameter and hiding ...
Read more >Prevent Windows PowerShell console from flashing up
I found the best method is to use VBScript as -WindowStyle Hidden will always briefly popup with PowerShell. Copy the below into a...
Read more >hiding powershell window running a script from a task ...
I have tried -WindowStyle Hidden but that doesn't do anything. ... I might be calling it incorrectly because the PS window still appears....
Read more >Run a PowerShell Script Without Displaying a Window
Use hidden as Window Style to Hide the PowerShell Window ... One simple way to do the script window hiding would be by...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You could have a
powershellw.exewhich would be a GUI application that doesn’t show a console window. Same as whatjavaw.exeandpythonw.exedo.Can
pwsh.exeget support for this or get pwshw.exe as suggested above? With this pwsh exe being new it seems like a great time to change the behaviour of-windowstyle hidden. Nobody has ever usedhiddenand thought “yep that’s what I wanted, flash some screen for a second”.It makes sense that powershell.exe can’t be changed after all this time and its legacy.