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.

How to Execute PowerShell Scripts Without Pop-Up Window
Tagged on:                                 

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

  • Permalink

    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
  • Permalink

    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
  • Permalink

    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

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Ad #native_company# — #native_desc# #native_cta#