windowspowershellconsole

Close Powershell Without Closing Exe


I'm on Windows 11. I need to run a program with Powershell. This program has its own UI. I want to be able to close the Powershell window without the program closing. But no matter what I do, as soon as I close the Powershell window, the program closes. Even using Start-Process to run the program, it still closes when the Powershell window is closed.

If I use Powershell to run Powershell, open the program within that Powershell using Start-Process, then Exit that Powershell, it stays open. But as soon as I close the original Powershell window, the program closes.


Solution

  • Use powershell.exe, the Windows PowerShell CLI, to non-interactively to launch your program, e.g.:

    powershell -NoProfile { & "$env:LOCALAPPDATA\Programs\Microsoft VS Code\Code.exe" }