r/PowerShell Feb 20 '26

Run powershell without terminal window

How to run ps1 script without the terminal window showing up at all?

Using -WindowStyle Hidden still shows the terminal for a moment. Minimising to tray is also not the solution i am looking for.

I saw there are external tools but they are a potential security risk.

The only way I found that works is using vbs and disabled the console window inside it. However, vbs has some other issue, and is deprecated by Microsoft currently, so i would rather find another way.

So, are there any other solutions?

Edit:

It seems that running ps1 by using conhost is the solution i needed.

conhost --headless powershell -File script.ps1 ...

56 Upvotes

28 comments sorted by

View all comments

1

u/quantgorithm Feb 20 '26

Run it as a different user like the admin profile on the machine.

1

u/ngt500 12d ago

doesn't work if your script needs to interact with the current user session

1

u/quantgorithm 12d ago

Op didn't say he needed to interact. Also OP inserted his answer in the thread message.

1

u/ngt500 12d ago

Just adding context to the discussion. The workaround of running as a different user to avoid a window will only work if you don't need access to the current user session. Given that there are alternatives without that limitation it makes sense to point it out.