需要帮助才能通过QTP 11执行plink - 它也应该等待命令完成 - 我到目前为止一直在尝试直到下面 - 但是收到错误:
Public Function test_exe()
Dim argStr
argStr = "cmd.exe /c " + Chr(34) & "plink.exe -load " + Chr(34) + session_name + Chr(34) + " -l " + Chr(34) + login_id + Chr(34) + " -pw " + Chr(34) + dns_pwd + Chr(34) + " -m " + Chr(34) + cmd_dir + "commands.txt" + Chr(34) + " >> " + Chr(34) + log_dir & log_filename + Chr(34) + Chr(34)
exeCount = Run_Test(argStr, log_dir + log_filename)
End Function
Public Function Run_Test(exeStr, ByVal logFile)
Dim pid, ExitEvent
Dim lineStr
Dim okFlg
Dim hProcess
exeCount = "0"
okFlg = 0
'pid = shell(exeStr, vbHide)
Dim csProcess
Set csProcess = DotNetFactory.CreateInstance("System.Diagnostics.Process")
Dim myProcess
Set myProcess = csProcess.Start(exeStr)
pid = myProcess.Id
hProcess = Extern.OpenProcess(PROCESS_QUERY_INFORMATION + SYNCHRONIZE, 0, pid)
ExitEvent = Extern.WaitForSingleObject(hProcess, 15000)
Extern.CloseHandle(hProcess)
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(logFile, ForWriting, True)
Do
f.writeLine lineStr
If InStr(1, lineStr, "/home/") > 0 Then okFlg = okFlg + 1
exeCount = "1"
Loop Until EOF(3)
f.close
If okFlg >= 1 Then
Run_Test = okFlg
Else
Run_Test = -1
End If
End Function
错误:"外部对象System.Diagnostics.Process :: Start抛出以下异常:系统找不到指定的文件Line(85):"设置myProcess = csProcess.Start(exeStr) ""