带有SendKeys方法的.vbs文件中的VBScript错误“语句结束”(VBScript Error “End of Statement” in .vbs File with SendKeys Method)
我正在尝试解析我的VBScript文件中的错误代码,当我使用send keys方法时,该错误代码出现在下面的代码中。 我从批处理文件中调用此.vbs文件,该文件具有我在此处存储为变量filename的参数。
这是我的.vbs文件:
Set args = WScript.Arguments arg1 = args.Item(0) Dim filename filename = ""&arg1&"" WshShell.Run("C:\root\bin\root.exe") WshShell.AppActivate "Administrator: Command Prompt" WshShell.SendKeys ".x analysis.C" WshShell.SendKeys ".x double_gaus.C" WshShell.SendKeys "c1->SaveAs("&filename&.pdf")" WshShell.SendKeys ".q" WScript.Quit 1批处理文件进入.vbs文件时,命令提示符窗口中出现的错误代码是:
C:\...\Root_VBS_Script_1.vbs(12, 46) Microsoft VBScript compilation error: Expected end of statement我的代码有什么问题? 还有其他问题吗?
I am trying to resolve an error code in my VBScript file that is occurring in the code below when I use the send keys method. I am calling this .vbs file from a batch file that has a parameter that I store here as the variable filename.
Here is my .vbs file:
Set args = WScript.Arguments arg1 = args.Item(0) Dim filename filename = ""&arg1&"" WshShell.Run("C:\root\bin\root.exe") WshShell.AppActivate "Administrator: Command Prompt" WshShell.SendKeys ".x analysis.C" WshShell.SendKeys ".x double_gaus.C" WshShell.SendKeys "c1->SaveAs("&filename&.pdf")" WshShell.SendKeys ".q" WScript.Quit 1The error code coming out of the command prompt window when the batch file proceesds into the .vbs file is:
C:\...\Root_VBS_Script_1.vbs(12, 46) Microsoft VBScript compilation error: Expected end of statementWhat is the problem in my code? And are there any other problems?
最满意答案
使用&来连接字符串。 你错过了第12行:
WshShell.SendKeys "c1->SaveAs("&filename&.pdf")"应该
WshShell.SendKeys "c1->SaveAs("&filename&.pdf&")"Use & to concatenate the strings. You missed that in line 12:
WshShell.SendKeys "c1->SaveAs("&filename&.pdf")"should be
WshShell.SendKeys "c1->SaveAs("&filename&.pdf&")"更多推荐
发布评论