我写了一个带有以下代码的.vbs文件。
Set WshShell=WScript.CreateObject("WScript.Shell")
WshShell.Run "cmd.exe"
WScript.Sleep 10000
WshShell.SendKeys "cd\"
WshShell.SendKeys "{ENTER}"
strUser = CreateObject("WScript.Network").UserName
WshShell.SendKeys "cd c:\users\"
WshShell.SendKeys strUser
WshShell.SendKeys "\desktop"
WshShell.SendKeys "{ENTER}"
WshShell.SendKeys "Java -jar "
fileName=inputbox("Please enter the .jar file name(without .jar extension)")
WScript.Sleep 10000
WshShell.SendKeys fileName
WshShell.SendKeys ".jar"
WshShell.SendKeys "{ENTER}"
我试图在qtp中使用systemutil.run函数运行此文件。它运行正常,但最后它显示“无法创建java虚拟机”。
如果我尝试双击.vbs文件,它将打开我的.jar文件。
请帮帮我。
答案 0 :(得分:0)
就个人而言,我还没有尝试,但它应该有效。试试:
fileName=inputbox("Please enter the .jar file name(without .jar extension)")
SystemUtil.Run "cmd","/c java -jar " & fileName & ".jar",""
只需更改路径即可 有关详情,请查看 this 链接。