带有SendKeys方法的.vbs文件中的VBScript错误“语句结束”

时间:2014-01-03 18:05:40

标签: batch-file vbscript compiler-errors sendkeys

当我使用send keys方法时,我正在尝试解析下面代码中出现的VBScript文件中的错误代码。我从批处理文件中调用此.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

我的代码有什么问题?还有其他问题吗?

1 个答案:

答案 0 :(得分:0)

使用&连接字符串。你错过了第12行:

WshShell.SendKeys "c1->SaveAs("&filename&.pdf")"

应该是

WshShell.SendKeys "c1->SaveAs("&filename&.pdf&")"