vbscript - VBScript - 800A0401 - 预期的语句结束
问题描述
我正在尝试使用 vbscript 调用uninstall.exe,但我得到了一个
800A0401 - 预期状态结束
错误。
strPath ="""%ProgramFiles%\qstopmotion 2.5.2\uninstall.exe""" Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Run strPath Set WshShell = Nothing Wscript.Sleep 5000 set svc=getobject("winmgmts:root\cimv2") sQuery="select * from win32_process where name='Au_.exe'" set cproc=svc.execquery(sQuery) iniproc=cproc.count Do While iniproc = 1 wscript.sleep 5000 set svc=getobject("winmgmts:root\cimv2") sQuery="select * from win32_process where name='Au_.exe'" set cproc=svc.execquery(sQuery) iniproc=cproc.count Loop set cproc=nothing set svc=nothing
错误出现在字符 63 处,即三引号的末尾。似乎无法正确逃离路径。有任何想法吗?
解决方案
VBScript 语法要求每一行代表一个语句,在问题的示例中,第一条语句是strPath
变量的结尾,因为编写了进一步的代码 VBScript 返回编译错误
预期的语句结束
你可以通过整理代码来解决这个问题,这样每个语句都是它自己的行;
strPath ="""%ProgramFiles%\qstopmotion 2.5.2\uninstall.exe"""
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run strPath
Set WshShell = Nothing
Wscript.Sleep 5000
set svc=getobject("winmgmts:root\cimv2")
sQuery="select * from win32_process where name='Au_.exe'"
set cproc=svc.execquery(sQuery)
iniproc=cproc.count
Do While iniproc = 1
wscript.sleep 5000
set svc=getobject("winmgmts:root\cimv2")
sQuery="select * from win32_process where name='Au_.exe'"
set cproc=svc.execquery(sQuery)
iniproc=cproc.count
Loop
set cproc=nothing
set svc=nothing
如果您确实希望这一切都在一行上运行 VBScript:
为此目的提供了语句分隔符 ( ),因此以下内容也是可以接受的,但可读性不强(不建议这样做);
strPath ="""%ProgramFiles%\qstopmotion 2.5.2\uninstall.exe""" : Set WshShell = WScript.CreateObject("WScript.Shell") : WshShell.Run strPath : Set WshShell = Nothing : Wscript.Sleep 5000 : set svc=getobject("winmgmts:root\cimv2") : sQuery="select * from win32_process where name='Au_.exe'" : set cproc=svc.execquery(sQuery) : iniproc=cproc.count : Do While iniproc = 1 : wscript.sleep 5000 : set svc=getobject("winmgmts:root\cimv2") : sQuery="select * from win32_process where name='Au_.exe'" : set cproc=svc.execquery(sQuery) : iniproc=cproc.count : Loop : set cproc=nothing : set svc=nothing
有用的链接
推荐阅读
- asp.net-core - ASP.NET Core 2 中不存在 deps.json
- python - 获取当前选定单元格的行号和列号
- python-3.x - Python3 无法正确接收图像
- python - 检查回归中的两个系数在 Python statsmodels 中是否不同
- php - PHP 7.0 move_uploaded_file() 不起作用
- javascript - Stats 命令在嵌入中显示未定义的数据
- java - 即使没有连接到代理,消费者也会继续调用 poll 方法
- html - HTTP 表单附加 URL 而不是重定向
- android - Xamarin Android:在微调器下拉列表中处理硬件密钥
- php - 组合多个数组,以便有多种选择