问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/13792429/is-there-a-way-to-start-a-program-minimized-with-vbscript-using-wscript-shell