宜昌颐和雅郡怎么样?:脚本VBS的应用 ~~质量 高分问题~!请各位编程高手光顾!~

来源:百度文库 编辑:中科新闻网 时间:2024/04/27 23:38:12
DIM objShell
set objShell=wscript.createObject("wscript.shell")
iReturn=objShell.Run("cmd.exe /C C:\addolcli\AddolC.exe", 0, TRUE)

以上这一段代码 “addolc.exe"是我要运行的程序。可是运行啦怎么改才能让它在运行的时候隐藏呢,或者是在后台运行,面或者怎么样才能让它运行的窗口不可见呢,或者在运行的的时候最小化也行,
希望有哪位编程高手指点一下,谢谢~!!~!

你现在的这个写法其实就是隐藏后台运行模式,可能是因为这个addolc.exe本身一运行就会出现在前台吧

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

希望不要搞坏事哦

你现在的这个写法其实就是隐藏后台运行模式,可能是因为这个addolc.exe本身一运行就会出现在前台吧

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.
你现在的这个写法其实就是隐藏后台运行模式,可能是因为这个addolc.exe本身一运行就会出现在前台吧

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.

恩好!

不会