Forum Discussion
5 Replies
Sort By
- Ryan_MoranValued Contributor
One possible solution would be to check the process' CPUUsage property until it has been idle for a period of time.
- joseph_michaudModerator
Perhaps you could examine the text of the window in a loop looking for what you want....
- jyothinbContributor
My question is, how to write a code to look for that last line in the screen shot. TC is not recognizing the text.
- AlexKarasChampion Level 3
Hi,
Assuming that the process exits when done, you may consider the function that was created ages ago:) (VBScript) :
'----------------------------------------------------------------------------- ' Function starts program and waits until it finishes Function ExecAndWaitForEnd(ByVal strProg, ByVal strArgs) Dim WshShell Dim oExec Dim strCommand Dim allOutput ExecAndWaitForEnd = -1 ' strProg = Utilities.AnsiQuotedStr(Trim(strProg), """") strProg = Trim(strProg) If (Left(strProg, 1) <> """") Then strProg = """" & strProg & """" End If strCommand = strProg & " " & strArgs ' oLogFile.WriteLineToLog (cLOGSTRINFO & "Executing: " & strCommand & "...") Set WshShell = CreateObject("WScript.Shell") Set oExec = WshShell.Exec(strCommand) Do While oExec.Status = 0 BuiltIn.Delay 500 Loop allOutput = ReadAllFromAny(oExec) Log.Message "ExecAndWaitForEnd(): Call exit code=" & oExec.ExitCode, _ "CmdLine: " & strCommand & vbCrLf & vbCrLf & "Output: " & allOutput ExecAndWaitForEnd = oExec.ExitCode ' oLogFile.WriteLineToLog (cLOGSTRINFO & "Done. (Return code = " & oExec.ExitCode & ")") Set oExec = Nothing Set WshShell = Nothing End Function '----------------------------------------------------------------------------- Function ReadAllFromAny(ByRef oExec) If Not oExec.StdOut.AtEndOfStream Then ReadAllFromAny = oExec.StdOut.ReadAll Exit Function End If If Not oExec.StdErr.AtEndOfStream Then ReadAllFromAny = cLOGSTRERROR & "STDERR: " & oExec.StdErr.ReadAll Exit Function End If ReadAllFromAny = -1 End Function '-----------------------------------------------------------------------------
Call sample:
Call ExecAndWaitForEnd("cmd.exe", _ "/c copy /y " + Utilities.AnsiQuotedStr(strSourceDB, """") + " " + _ Utilities.AnsiQuotedStr(strTargetDB, """"));
Related Content
- 6 years agomissydr