VBScript - 800A0401 - 语句预期结束
VBScript - 800A0401 – Expected End of Statement
我正在尝试使用 vbscript 调用 uninstall.exe,但我得到了
800A0401 - Expected End of state
错误。
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 个字符,它位于 tripe 引号的末尾。似乎无法正确逃避路径。有什么想法吗?
VBScript 语法要求每一行代表一个语句,在问题的例子中第一条语句是你的 strPath
变量的结尾,因为进一步的代码写成 VBScript returns 编译错误
Expected end of statement
您可以通过整理代码来解决这个问题,这样每个语句都是独立的行;
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
有用的链接
- VBScript, purpose of colon?
我正在尝试使用 vbscript 调用 uninstall.exe,但我得到了
800A0401 - Expected End of state
错误。
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 个字符,它位于 tripe 引号的末尾。似乎无法正确逃避路径。有什么想法吗?
VBScript 语法要求每一行代表一个语句,在问题的例子中第一条语句是你的 strPath
变量的结尾,因为进一步的代码写成 VBScript returns 编译错误
Expected end of statement
您可以通过整理代码来解决这个问题,这样每个语句都是独立的行;
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
有用的链接
- VBScript, purpose of colon?