You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PowerShell argument WindowStyle -Hidden is not respected when the default terminal application is Windows Terminal #12464
Set Windows Terminal as the default terminal application:
.
Make sure to save changes to Windows Terminal Settings, and then using Windows Run, run pwsh -WindowStyle Hidden -Command Sleep 10:
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.
Note: There is no repro for this issue with Windows Console Host as the default terminal application.
Reacted by Teddy Z, neoqueto, Chris-Robin, fuba, Pavel, Andrei Toroplean, Eddie Carswell, Peter Briggs, Marek Buko, Michele Cancilla and 8 more
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.
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.
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.
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.
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.
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.
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):
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).
Reacted by O l e s C h r i, 0lini, Tarun Kumar S, maratfs and Mathias
Activity
zadjii-msft commentedon Feb 11, 2022
PowerShell/PowerShell#3028 looks like it's related. This probably requires quite a bit of thinking...
malxau commentedon Feb 11, 2022
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.
sachinjoseph commentedon Feb 12, 2022
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 Hiddenand not using this argument when WT is the default terminal application.sachinjoseph commentedon Feb 13, 2022
This is a blocker for many applications such as rush that use PowerShell to run background tasks. Rush issue tracked here.
fantesykikachu commentedon Jul 2, 2022
just to note, Terminal also doesn't allow the old vbs script trick.
CreateObject("WScript.Shell").Run <batch script>, 0with 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.
20 remaining items
pavichokche commentedon Jan 10, 2025
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.
jflieben commentedon Feb 20, 2025
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
alessiot89 commentedon Jun 8, 2025
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.
madhanmaaz commentedon Jul 15, 2025
Try this:
test.batstart /MIN powershell -WindowStyle Hidden -c "sleep 5; echo 'content' > success.txt"2025-07-15.13-09-04.mp4
daikictrl commentedon Dec 21, 2025
What then is then is the command to run background processes??
oldium commentedon Dec 21, 2025
Why should we try anything that does not work? What is the point actually?
MV10 commentedon Dec 26, 2025
Coming up on 4 years since this was reported and sequestered into the backlog.
Is anybody actually working on this?
KG-droid commentedon Dec 26, 2025
Would also like to know this, in a business setting we just can't use terminal because of this.
LbISS commentedon Jan 8, 2026
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.
oldium commentedon Jan 8, 2026
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):
Use
powershell.exeorpwsh.exeas 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).Windows: start the service through conhost --headless so it has no wi…
fix(scripts): el vigilante del emulador dejaba una terminal abierta y…
fix(scripts): el vigilante del emulador dejaba una terminal abierta y…
docs(kernel): auto-launch review (F1-F21), read-only
fix(desktop): Windows 업데이트 뒤 CMD 창이 뜨고 그 창을 닫으면 앱도 꺼지던 문제 수정