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

时光总嘲笑我的痴心妄想 提交于 2019-12-23 12:49:29

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!