带有SendKeys方法的.vbs文件中的VBScript错误“语句结束”(VBScript Error “End of Statement” in .vbs File with SendKeys M

编程入门 行业动态 更新时间:2024-10-26 08:30:58
带有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 1

The 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 statement

What 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&")"

更多推荐

本文发布于:2023-07-25 22:20:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1266993.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:语句   错误   结束   文件   方法

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!