Skip to content

Powershell -WindowStyle Hidden still shows a window briefly #3028

Open

Description

Steps 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

Activity

  1. BrucePay commented on Jan 25, 2017

    @BrucePay
    Collaborator

    powershell.exe is a console application. The console window is automatically created by the OS when the process starts. The powershell.exe code that processes -WindowStyle Hidden is therefore executed after the console window is opened hence the flash. To fix this, we would need the equivalent of wscript i.e. a win32 host application instead of a console host application. 

  2. added
    Resolution-ExternalThe issue is caused by external component(s).
    Issue-Enhancementthe issue is more of a feature request than a bug
    Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributors
    and removed
    Resolution-ExternalThe issue is caused by external component(s).
    on Feb 2, 2017
  3. SteveL-MSFT commented on Feb 2, 2017

    @SteveL-MSFT
    Member

    Given there's no code change we can do in powershell.exe to address this, I've changed this issue to a feature request to have a wscript-like host to support this type of scenario

  4. rednoah commented on Jun 26, 2017

    @rednoah

    You could have a powershellw.exe which would be a GUI application that doesn't show a console window. Same as what javaw.exe and pythonw.exe do.

  5. Jackbennett commented on Feb 16, 2018

    @Jackbennett

    Can pwsh.exe get 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 used hidden and 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.

  6. SteveL-MSFT commented on Feb 21, 2018

    @SteveL-MSFT
    Member

    I would support a community contribution to add pwshw.exe

  7. gtalton commented on Feb 21, 2018

    @gtalton

    Agree .. this would be consistant with other language executables and solve me having to currently wrap my powershell scripts in vbs scripts.

  8. iSazonov commented on Feb 21, 2018

    @iSazonov
    Collaborator

    Technically we could do like https://github.com/AvaloniaUI/Avalonia/wiki/Hide-console-window-for-self-contained-.NET-Core-application

    editbin.exe /subsystem:windows yourapp.exe

    But I wonder - if PowerShell Core is portable what is expected behavior on Unix? Can we be unified on all platforms?
    Related discussion https://github.com/dotnet/cli/issues/296 It also mentions that we could use GUI subsystem.

    Maybe Michael Klement (@mklement0) have any thoughts?

  9. SteveL-MSFT commented on Feb 21, 2018

    @SteveL-MSFT
    Member

    Ilya (@iSazonov) -WindowStyle isn't supported on non-Windows

  10. 136 remaining items

  11. theJasonHelmick commented on Mar 19, 2025

    @theJasonHelmick
    Collaborator

    The WG-Interactive is re-reviewing this and will discuss with Terminal and Console.

  12. esdnm commented on Aug 7, 2025

    @esdnm

    if you want to run this when user is logged in without highest privileges. just dont use the arguments box. put everything immediately after powershell.exe and make sure that -windowstyle hidden is first.
    image

    I tried this, on one computer it worked, but on another it didn't run the script, results showed "The parameter is incorrect"

  13. esdnm commented on Aug 10, 2025

    @esdnm

    While running in full screen mode e.g. PowerPoint presentation, if the scheduled task runs, then the Taskbar becomes and remains visible during the whole duration of script run time. (And the usual flash at the start)

  14. esdnm commented on Aug 26, 2025

    @esdnm

    I figured out a different solution to this. It entirely hides the console window, as in, it never appears as a task bar icon, even when running under user context.

    So, for your scheduled task action, use this...

    <Exec>
    <Command>C:\Windows\System32\conhost.exe</Command>
    <Arguments>--headless powershell.exe -WindowStyle Hidden -NoProfile -NonInteractive -file "C:\Temp\MyScript.ps1"</Arguments>
    </Exec>
    

    This worked! Thank you.

  15. crazylegs1277-web commented on Sep 11, 2025

    @crazylegs1277-web

    2017 - crickets
    2018 - crickets
    2019 - crickets
    2020 - crickets
    2021 - crickets
    2022 - crickets
    2023 - crickets
    2024 - crickets
    March 16 2025 - ericohlin (@ericohlin): Hey guys since Microsoft isnt doing anything about this, here's another way
    March 16 2025 - Dustin L. Howett (@DHowett): Um wait, your not supposed to use that its unreliable. PowerShell team, please stop them!!!!!
    March 19 2025 - Jason Helmick (@theJasonHelmick): We're going to look into

    LMAO! Thanks for this comedy and conhost.exe --headless ericohlin (@ericohlin). I guess I'll be using this like others until the PoSh team can come through or Dustin L. Howett (@DHowett) can come up with a better explanation than "I said so, I'm the owner"

    “The reasonable man adapts himself to the world: the unreasonable one persists in trying to adapt the world to himself. Therefore all progress depends on the unreasonable man.”
    ― George Bernard Shaw

  16. SeidChr commented on Sep 11, 2025

    @SeidChr

    crazylegs1277-web i feel left out now 🫣
    #3028 (comment)

  17. AntifaUnity commented on Nov 20, 2025

    @AntifaUnity

    I figured out a different solution to this. It entirely hides the console window, as in, it never appears as a task bar icon, even when running under user context.

    So, for your scheduled task action, use this...

    <Exec>
    <Command>C:\Windows\System32\conhost.exe</Command>
    <Arguments>--headless powershell.exe -WindowStyle Hidden -NoProfile -NonInteractive -file "C:\Temp\MyScript.ps1"</Arguments>
    </Exec>
    

    This worked. Absolutely legendary work Sir.

    I did have to add '-ExecutionPolicy Bypass'.

  18. oldium commented on Nov 20, 2025

    @oldium

    Well, this is getting even more ridiculous. This is how I used NirCmd, originally installed via winget, to run windowless powershell:

    <Exec>
    <Command>C:\Users\user\AppData\Local\Microsoft\WinGet\Packages\NirSoft.NirCmd_Microsoft.Winget.Source_8wekyb3d8bbwe\nircmd.exe</Command>
    <Arguments>execmd pwsh.exe -NonInteractive -NoProfile -NoLogo -File C:\Users\user\bin\vpn-disconnected.ps1</Arguments>
    </Exec>
    

    But now the NirCmd package was removed from WinGet package index and they are rejecting to include it back. Seriously, Microsoft? You are removing the ways we are running the tools without making it working in the first place.


    Update: switched from winget to scoop to install nircmd. 🤷


    Update 2: welcome another happy user of conhost.exe 😁

  19. adipiciu commented on Mar 12, 2026

    @adipiciu

    There is another workaround using a .js wrapper file. This way you can replace the vbscript silent wrapper solution which is deprecated.

    var objShell = new ActiveXObject("WScript.Shell");
    var strCMD = 'powershell.exe -ExecutionPolicy ByPass -NoProfile -WindowStyle Hidden -NonInteractive -NoLogo -File "Path_To_Your_PS_Script.ps1"';
    objShell.Run(strCMD, 0);
    

    Just replace your .vbs with the above .js file. The command to run powershell silently will be the same:

    wscript.exe SilentWrapper.js

    The script can be modified to accept the powershell script file as an argument if needed.

    This solution is a fast in-place upgrade to vbscript wrapper, if you don't want to use a compiled C# exe wrapper or the conhost.exe hack.

  20. TheBestPessimist commented on Mar 12, 2026

    @TheBestPessimist

    Come on microsoft. Use that copilot that you forcefully shove down all our throats to actually deliver a useful feature requested for 10 years very very soon.

  21. alexandj42 commented on Apr 8, 2026

    @alexandj42

    Wow. I was not expecting to run into what I thought was a small issue in Powershell behavior, and find that it is something that has been ongoing for over 9 years now. I will be looking into the vbscript or conhost workarounds, but it sure would be nice to get some attention from MS on this.

  22. luciusbono commented on Apr 8, 2026

    @luciusbono

    Good luck everyone. I’ve moved to Linux and have never been happier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    In-PRIndicates that a PR is out for the issueIssue-Enhancementthe issue is more of a feature request than a bugKeepOpenThe bot will ignore these and not auto-closeOS-WindowsWG-Interactive-Consolethe console experienceWG-NeedsReviewNeeds a review by the labeled Working Group

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions