How to Execute PowerShell Scripts Without Pop-Up Window

PowerShell scripts are hard to run without any kind of popup. Without a small workaround, it may even be impossible, even if you specify the -WindowStyle Hidden switch - this will only result in the PowerShell window blinking up for a split second and disappearing afterwards.

You can circumvent this issue by launching the PowerShell script from a small VBScript which looks as follows:

command = "powershell.exe -nologo -command C:\Users\howtoforge\Desktop\loop.ps1"
set shell = CreateObject("WScript.Shell")
shell.Run command,0

Save the script as .vbs file. The -command switch is followed by the location of your PowerShell script - give the full path here (my PS script is on C:\Users\howtoforge\Desktop and is called loop.ps1). This VBS frame will cause the PowerShell script to work silently; it will no longer display any cmd window.

6 thoughts on “How to Execute PowerShell Scripts Without Pop-Up Window”

  1. Avatar

    This worked a treat! Thanks so much!

    Reply
  2. Avatar

    Ok this is great, but I am trying to run two commands hidden at the same time with a delay. This is a door relay turn on wait 500 milliseconds and turn off looks like this to turn it on works great.

    command = “powershell.exe -nologo -command c:\usbrelay\usbrelay.exe -c:5 -r:1#1”
    set shell = CreateObject(“WScript.Shell”)
    shell.Run command,0

    Reply
  3. Avatar

    You can also use PowerGUI (it’s free) and compile your ps1 script into an executable that can launch with the console window hidden.

    Reply
  4. Avatar

    but does it complete the execution if a pop-up window prompts you for an answer otherwise? e.g. i am dealing with several uninstall executables that are requesting me to select OK to continue or acknowledge that they’ve completed.

    Reply
  5. Avatar

    This is (and works) great! Thanks a lot

    Reply
  6. Avatar

    Can this be ran with Start-Process command?

    Reply

Leave a Comment

*