Skip to content

PowerShell argument WindowStyle -Hidden is not respected when the default terminal application is Windows Terminal #12464

Open

Description

Windows Terminal version

1.12.10393.0

Windows build number

Microsoft Windows NT 10.0.22549.0

Other Software

Software Version
PowerShell.exe Multiple Versions
pwsh.exe Multiple Versions

Steps to reproduce

  1. Set Windows Terminal as the default terminal application:
    .
    image

  2. Make sure to save changes to Windows Terminal Settings, and then using Windows Run, run pwsh -WindowStyle Hidden -Command Sleep 10:
    image

Expected Behavior

A new PowerShell process launches (Windows Terminal), and it isn't visible. The window may flash for a second. PowerShell window shouldn't be displayed when it's launched with WindowStyle -Hidden.

Actual Behavior

A new PowerShell process launches (on Windows Terminal), and it is visible and remains visible (and waits) for 10 seconds.

image

Note: There is no repro for this issue with Windows Console Host as the default terminal application.

Activity

  1. added
    Issue-Bug
    on Feb 11, 2022
  2. ghost added
    Needs-Triage
    on Feb 11, 2022
  3. ghost added
    Needs-Tag-Fix
    on Feb 11, 2022
  4. zadjii-msft commented on Feb 11, 2022

    @zadjii-msft
    Member

    PowerShell/PowerShell#3028 looks like it's related. This probably requires quite a bit of thinking...

  5. added
    Issue-Feature
    Product-Terminal
    and removed
    Issue-Bug
    on Feb 11, 2022
  6. ghost removed
    Needs-Tag-Fix
    on Feb 11, 2022
  7. malxau commented on Feb 11, 2022

    @malxau
    Contributor

    Dustin wrote a spec for this a while back that doesn't seem to have ever been merged:

    #7337
    https://github.com/microsoft/terminal/blob/ec27049553e9ca2135068edf8a9946a9d94ae2c4/doc/specs/%237335%20-%20Console%20Allocation%20Policy.md

    Looking at it now the odd part is asking console processes to call ShowWindow. That doesn't seem to fit well with what Terminal is trying to do w.r.t. multi-tab, multi-pane, etc.

  8. sachinjoseph commented on Feb 12, 2022

    @sachinjoseph
    Author

    PowerShell/PowerShell#3028 looks like it's related. This probably requires quite a bit of thinking...

    The console window being shown for a second may still be tolerable but with WT the window isn't hidden at all - there's no difference between using the PowerShell argument -WindowStyle Hidden and not using this argument when WT is the default terminal application.

  9. sachinjoseph commented on Feb 13, 2022

    @sachinjoseph
    Author

    This is a blocker for many applications such as rush that use PowerShell to run background tasks. Rush issue tracked here.

  10. removed
    Needs-Triage
    on Apr 26, 2022
  11. fantesykikachu commented on Jul 2, 2022

    @fantesykikachu

    just to note, Terminal also doesn't allow the old vbs script trick.
    CreateObject("WScript.Shell").Run <batch script>, 0
    with conhost this would run the batch script but no window is shown both on screen and on the taskbar.
    however with Terminal as the process that runs batch scripts, the script runs but the terminal window is shown.

  12. 20 remaining items

  13. pavichokche commented on Jan 10, 2025

    @pavichokche

    This important detail should be added to the documentation, since it still just mentions using --no-console as though it will work in modern Windows versions.

  14. jflieben commented on Feb 20, 2025

    @jflieben

    For those reading this, using Intune you can auto-remediate this on managed W11 machines by forcing the old console as default:

    https://github.com/jflieben/assortedFunctionsV2/tree/main/DefaultTerminalRemediation

  15. alessiot89 commented on Jun 8, 2025

    @alessiot89

    Bump this.
    Other application devs are trying to workaround against this by getting back the HWND just calling immediately ShowWindow() just after calling SetForegroundWindow(). Except this isn't a fix (suggested by multiple source) but a wrong solution that may give the wrong HWND even of other applications with potential disaster. Please fix this. Windows terminal is basically default on many windows 11 systems and this is creating really annoying behaviours. Some anti-malware may also trigger such workaround behaviour as harmful.
    This is not a minor bug, this is an API breaking things that you have to fix. Or, at least, provide a suitable easy solution for all 3rd party apps developers that wanna have SW_HIDE to work as intended, better to keep SW_HIDE to work as always has been.

  16. madhanmaaz commented on Jul 15, 2025

    @madhanmaaz

    Try this: test.bat

    start /MIN powershell -WindowStyle Hidden -c "sleep 5; echo 'content' > success.txt"
    2025-07-15.13-09-04.mp4
  17. daikictrl commented on Dec 21, 2025

    @daikictrl

    What then is then is the command to run background processes??

  18. oldium commented on Dec 21, 2025

    @oldium

    Try this: test.bat

    start /MIN powershell -WindowStyle Hidden -c "sleep 5; echo 'content' > success.txt"
    2025-07-15.13-09-04.mp4

    Why should we try anything that does not work? What is the point actually?

    Image
  19. MV10 commented on Dec 26, 2025

    @MV10

    Coming up on 4 years since this was reported and sequestered into the backlog.

    Is anybody actually working on this?

  20. KG-droid commented on Dec 26, 2025

    @KG-droid

    Coming up on 4 years since this was reported and sequestered into the backlog.

    Is anybody actually working on this?

    Would also like to know this, in a business setting we just can't use terminal because of this.

  21. LbISS commented on Jan 8, 2026

    @LbISS

    Yeah, just've pent a day trying to understand why console applications are not minimized properly in the Win 11... I understand, that it's not possible to keep everything backward compatible. But would be great to have at least new API to work with the state of Windows Terminal. Otherwise it's just limiting the solution the developer can provide for Win 11 users.

  22. oldium commented on Jan 8, 2026

    @oldium

    For anybody new in this thread, the actually working solution to hide the console window when starting up is to use conhost.exe - PowerShell/PowerShell#3028 (comment):

    For example execute this from Windows Run (Ctrl+R):

    C:\Windows\System32\conhost.exe --headless pwsh.exe -NoProfile -Command Sleep 10 
    

    Use powershell.exe or pwsh.exe as you need.

    Although this is not recommended by the maintainer of the conhost.exe, he have not provided any working alternative. So feel free to use this one until it breaks (it still works).

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

    Area-DefAppIssue-FeatureProduct-Terminal

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions