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
When "Start-Sleep -second 5" on aaa-v2.ps1,The parent powershell process will soon return to focus.
When "Start-Sleep -second 55" on aaa-v2.ps1,The parent powershell process will long time return to focus.
Expected behavior
Return to focus right now after The parent powershell process script end .
Actual behavior
ps window loses focus after start-process
Error details
Cause:
The powershell window loses focus after start-process.
When the "start-process process" ends, focus will resume, depending on the length of the process execution time.
If your script contains "start-process",
in order to retrieve the focus of the powershell window, you will frequently click on the window,
I want to write a script to fix it.
But it was found the script works normally in powershell, but does not work in win terminal.
Environment data
powershell 5.1.19041.1320 on win10
PowerShell 7.4.0-preview.3 on win10
all version win terminal.
parent powershell child pwsh,
parent pwsh child powershell,
Visuals
No response
The text was updated successfully, but these errors were encountered:
By design, Start-Process makes the newly launched process' main window the active window (the foreground window with the input focus).
Since your intent appears to be to launch a hidden PowerShell instance, use -WindowStyle Hiddenwith Start-Process rather than the -WindowStyle hiddenCLI parameter, which bypasses the problem of losing focus.
(With the CLI parameter, a visible console window is still invariably created initially, when PowerShell is launched, and is only then hidden by PowerShell itself - at which point the focus has already been lost; see also:
Prerequisites
Steps to reproduce
When "Start-Sleep -second 5" on aaa-v2.ps1,The parent powershell process will soon return to focus.
When "Start-Sleep -second 55" on aaa-v2.ps1,The parent powershell process will long time return to focus.
Expected behavior
Return to focus right now after The parent powershell process script end .
Actual behavior
ps window loses focus after start-process
Error details
Cause:
The powershell window loses focus after start-process.
When the "start-process process" ends, focus will resume, depending on the length of the process execution time.
If your script contains "start-process",
in order to retrieve the focus of the powershell window, you will frequently click on the window,
I want to write a script to fix it.
But it was found the script works normally in powershell, but does not work in win terminal.
Environment data
Visuals
No response
The text was updated successfully, but these errors were encountered: