Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Waiting for the process to exit
#1
Hi,
I encountered a problem, described as follows:
 
1. A.exe is a resident process, It is displayed continuously in the Task Manager without a GUI interface
2. B.exe relays the command line to A.exe and exits immediately! Then a new A.exe process will be generated, and the process will exit after execution is completed
3. But B.exe There is no provided parameter for waiting for New A.exe exit

With the following PowerShell code, I can achieve waiting for the new A.exe to exit. How achieve the same effect in QM?

Thank you in advance for any suggestions and help.
David

Powershell Code:
Code:
Copy      Help
$relaysProgramPath = "C:\B.exe"
$arguments = '/start "My arg"'
Start-process -FilePath $relaysProgramPath -ArgumentList $arguments

# Set the upper limit of loop attempts and the interval time (second)
$maxAttempts = 30
$interval = 1

#Loop to check the number of processes, maximum 30 attempts
for ($i = 1; $i -le $maxAttempts; $i++)
{
    # Get the number of "A.exe" processes
    $processCount = (Get-process -Name "A").Count
    
    # Check the number of processes
    if ($processCount -le 1)
    {
        # If the number of processes is less than or equal to 1, break the loop
        break
    }
    
    # Wait for the specified interval time
    Start-Sleep -Seconds $interval
}
"New A.exe has exited"


Messages In This Thread
Waiting for the process to exit - by Davider - 07-08-2023, 02:32 AM
RE: Waiting for the process to exit - by Davider - 07-08-2023, 10:27 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)