奔驰gla200三厢图片:VBS的RUN函数本身带三个参数-隐藏后台运行模式 - 饿狼的日志 - 网易博客

来源:百度文库 编辑:偶看新闻 时间:2024/04/29 05:47:05

VBS的RUN函数本身带三个参数-隐藏后台运行模式

com-vbs 2009-04-26 00:42:19 阅读975 评论0   字号: 订阅

VBS的RUN函数本身带三个参数-隐藏后台运行模式

1.代码事例:

DIM objShell
set objShell=wscript.createObject("wscript.shell")
iReturn=objShell.Run("cmd.exe /C C:\addolcli\AddolC.exe", 0, TRUE)


VBS的RUN函数本身带三个参数,第一个参数就是你要运行的程序

第二个参数就是用来控制运行窗口模式 有0-9模式
其中0是隐藏后台运行,6是最小化运行

具体可以参数MSDN帮助文档

SW_HIDE 0 Hides the window and activates another window.
SW_MINIMIZE 6 Minimizes the specified window and activates the next top-level window in the Z order.
SW_RESTORE 9 Activates and displays the window. If the window is minimized or maximized, Windows restores it to its original size and position. An application should specify this flag when restoring a minimized window.

 

Run的第三个参数将允许我们防止相关程序以并发方式运行。您可将第三个参数赋值为True,以便指示脚本停留在使用Run方法的代码行并保持等待状态,直到已被激活的程序运行完毕。我们已经知道了因未设定该参数所产生的后果,该参数在缺省状态下被设定为False,而这种设置必将导致两个程序同时运行。也就是说TRUE值时必须等待这个脚本完成才运行其他程序,而false时可能还未运行完又执行另外一个脚本


还有一种方式的隐藏运行

set ws=wscript.createobject("wscript.shell")
ws.run "bat.bat /start",0

将上面代码写在记事本里保存扩展名为**.vbs 。
以下是调用的批处理。即是上面中的bat.bat文件。
@ECHO OFF
C:\addolcli\AddolC.exe
@ECHO OFF