RunHidden launches (almost) any script or console application with the console window 100% suppressed.
It runs PowerShell scripts (ps1 extension), batch files (cmd and bat extensions), and Python scripts (py extension) directly via their respective interpreter (PowerShell.exe, Cmd.exe, and Python.exe). Those interpreters are assumed to be on the path.
All other script types are run via Cmd.exe (which will usually run the correct interpreter automatically). This approach may not work for everything. If you have a script type that you would like handled directly by its interpreter, please open an issue and I’ll try to add it.
Obviously, this is meant for scripts and exes that do not require any console input and do something more than just produce some console output.
RunHidden passes through all command line arguments and is compatible with paths and arguments containing spaces. For PowerShell script arguments, it’s not necessary to double up trailing, quoted backslashes, but it’s okay to do that. For example, all of the following will work correctly:
RunHidden Script01.ps1 “C:\Some Folder”
RunHidden Script01.ps1 “C:\Some Folder\”
RunHidden Script01.ps1 “C:\Some Folder\\”
RunHidden.exe is more convenienent than equivalent VBScript or JScript solutions. The main advantage is that it’s easier to use with Windows shortcuts.
Note: Some antivirus software may falsely detect the download as a virus. This can happen any time you download a new executable and may require extra steps to whitelist the file.
Example 1:
Run a script hidden:
RunHidden C:\Scripts\Script01.ps1
Example 2:
Run with two arguments:
RunHidden C:\Scripts\Script01.cmd /theme=1 /size=1
Example 3:
Run from a folder with a space in its name:
RunHidden "C:\My Scripts\Script01.ps1"
Example 4:
Pass one argument that contains a space:
RunHidden "C:\My Scripts\Script01.ps1" "C:\Some Folder\"
Example 5:
Pass two arguments that contain spaces:
RunHidden "C:\My Scripts\Script01.ps1" "C:\Some Folder1\" "C:\Some Folder2\"
Debugging can be tricky when you hide the console, but you can easily determine if your script is receiving the correct arguments from the command line, by calling this little messagebox program from your script.