VBScript-800A0401–预期的语句结尾

VBScript-800A0401–预期的语句结尾,vbscript,Vbscript,我正试图使用vbscript调用uninstall.exe,但我得到一个 800A0401-预期状态结束 错误 strPath ="""%ProgramFiles%\qstopmotion 2.5.2\uninstall.exe""" Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Run strPath Set WshShell = Not

我正试图使用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 设置WshShell=WScript.CreateObjectWScript.Shell WshShell。运行strPath 设置WshShell=Nothing Wscript.Sleep 5000 设置svc=getobjectwinmgmts:root\cimv2 sQuery=从win32_进程中选择*,其中name='Au'.exe' 设置cproc=svc.execquerysQuery iniproc=cproc.count 当iniproc=1时执行 wscript.sleep 5000 设置svc=getobjectwinmgmts:root\cimv2 sQuery=从win32_进程中选择*,其中name='Au'.exe' 设置cproc=svc.execquerysQuery iniproc=cproc.count 环 设置cproc=nothing 设置svc=nothing 如果您确实希望所有这些都在一行上运行,VBScript提供语句分隔符字符:为此,以下内容也是可以接受的,但可读性不强,建议不要这样做

strPath=%ProgramFiles%\qstopmotion 2.5.2\uninstall.exe:Set WshShell=WScript.CreateObjectWScript.Shell:WshShell.Run strPath:Set WshShell=Nothing:WScript.Sleep 5000:Set svc=getobjectwinmgmts:root\cimv2:sQuery=select*from win32_进程,其中name='Au.exe':Set cproc=svc.execquerysquerysquery:iniproc=cproc.count:Do While iniproc=1:wscript.sleep 5000:set svc=getobjectwinmgmts:root\cimv2:sQuery=select*自win32_进程,其中name='Au'.exe':set cproc=svc.execqueryqueryquery:iniproc=cproc.count:Loop:set cproc=nothing:set svc=nothing 有用的链接
因为字符串的结尾是该特定语句的预期结尾。每个语句都应该以回车结束,或者如果您想让语句跨越相同的行,请在每个语句的结尾处用:分隔它们。@K-Dawg您在说什么VBScript中没有end Set这样的语句??您的意思是将代码全部作为一行发布,还是实际上在多行上发布?如果是的话,请用你的代码来修复它。@K-Dawg可能根本不是VBScript?该文档是针对VB.Net的,而基于Visual Basic编程语言的文档是基于.Net CLR的完全不同的技术。供参考,这是。@user692942啊,谢谢。我已经有一段时间没有以任何形式使用VB了。我会删除我最初的评论,我认为在使用Set之后,您可能会丢失End Set,这样以后就不会给任何人错误的方向盘。