Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 使用SendKeys方法在.vbs文件中出现VBScript错误“语句结束”_Batch File_Vbscript_Compiler Errors_Sendkeys - Fatal编程技术网

Batch file 使用SendKeys方法在.vbs文件中出现VBScript错误“语句结束”

Batch file 使用SendKeys方法在.vbs文件中出现VBScript错误“语句结束”,batch-file,vbscript,compiler-errors,sendkeys,Batch File,Vbscript,Compiler Errors,Sendkeys,我正在尝试解决VBScript文件中的一个错误代码,该错误代码在我使用send keys方法时出现在下面的代码中。我从一个批处理文件调用这个.vbs文件,该批处理文件包含一个参数,我将该参数存储在这里作为变量文件名 这是我的.vbs文件: Set args = WScript.Arguments arg1 = args.Item(0) Dim filename filename = ""&arg1&"" WshShell.Run("C:\root\bin\root

我正在尝试解决VBScript文件中的一个错误代码,该错误代码在我使用send keys方法时出现在下面的代码中。我从一个批处理文件调用这个.vbs文件,该批处理文件包含一个参数,我将该参数存储在这里作为变量文件名

这是我的.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

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

使用&来连接字符串。你在第12行没有看到:

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

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

是否尝试将WshShell.SendKeys c1->SaveAs&filename&.pdf更改为WshShell.SendKeys c1->SaveAs&filename&.pdf&?