Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to start a program minimized with VBScript using WScript.Shell?

Here is some example code I have right now to launch an app:

Set objShell = Wscript.CreateObject("WScript.Shell")     
objShell.Run """C:\Program Files\Handbrake\HandBrakeCLI.exe"""

I tried the following to launch the app minimized but it didn't work. I'm assuming this only works from a normal command prompt?

Set objShell = Wscript.CreateObject("WScript.Shell")     
objShell.Run "start /MIN ""C:\Program Files\Handbrake\HandBrakeCLI.exe"""

I've also tried launching a shortcut (which just gave a null error and the script couldn't run) as well as trying to do a sendkeys to minimize it which didn't work at all.

This is from a VBScript running via cscript.exe by the way.

Does anyone know how I can start this app minimized within VBScript?

like image 875
Ethan Allen Avatar asked Dec 09 '12 22:12

Ethan Allen


1 Answers

Check the docs and use the second parameter of the .Run method.

Evidence:

set s = createobject("WScript.Shell")
s.run "notepad", 2

starts Notepad minimized.

like image 176
Ekkehard.Horner Avatar answered Sep 28 '22 17:09

Ekkehard.Horner