windowspowershellscriptingbatch-filesilent

How to run a PowerShell script without displaying a window?


How is it possible to run a PowerShell script without displaying a window or any other sign to the user?

In other words, the script should run quietly in the background without any sign to the user.

Extra credit for an answer that does not use third party components :)


Solution

  • You can either run it like this (but this shows a window for a while):

    PowerShell.exe -WindowStyle hidden { your script.. }
    

    Or you use a helper file I created to avoid the window called PsRun.exe that does exactly that. You can download the source and exe file from Run scheduled tasks with WinForm GUI in PowerShell. I use it for scheduled tasks.

    Edited: as Marco noted this -WindowStyle parameter is available only for V2 and above.