首页 > 其他 > 详细

使用Wscript/cscript调用VB脚本

时间:2018-07-26 20:45:43      阅读:184      评论:0      收藏:0      [点我收藏+]

●强制用Wscript.exe执行

SET Wshell=CreateObject("Wscript.Shell")

if lcase(right(Wscript.fullName,11)) = "cscript.exe" then
Wshell.run "wscript.exe //nologo " & chr(34) & wscript.scriptfullname & chr(34)
Wscript.quit
else
Wscript.echo "执行代码写在此处"
end if


●强制用Cscript.exe执行:

SET Wshell=CreateObject("Wscript.Shell")

if lcase(right(Wscript.fullName,11)) = "wscript.exe" then

Wshell.run "cmd /k cscript.exe //nologo " & chr(34) & wscript.scriptfullname & chr(34)
Wscript.quit
else
Wscript.echo "执行代码写在此处"
end if

●调试:
在cmd窗口输入:
Wscript.exe /X test.vbs
会弹出visual studio调试窗口,即可完成调试。

或者:
利用消息框调试:
WScript.Sleep(10000) //sleep 10秒
WScript.Echo "Success" //在wscript.exe下显示消息弹框
Wshell.Popup "aaabbb" //在cscript.exe下显示消息弹框

cmd /k表示 执行完后面的命令时,窗口保留,/c表示窗口关闭

/后面表示选项,常用用下列几种,你可以在命令行下输入 cmd /?看到:

/C 执行字符串指定的命令然后终断
/K 执行字符串指定的命令但保留
/S 在 /C 或 /K 后修改字符串处理(见下)
/Q 关闭回应
/D 从注册表中停用执行 AutoRun 命令(见下)
/A 使向内部管道或文件命令的输出成为 ANSI
/U 使向内部管道或文件命令的输出成为 Unicode

使用Wscript/cscript调用VB脚本

原文:https://www.cnblogs.com/mountain2011/p/9373858.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!