Jump to content
youtuber

RunWait ProcessWaitClose issues

Recommended Posts

youtuber

My friends want to run an exe file and then close it, but the program does not shut down.

$aOpenFiles = FileOpenDialog("", @ProgramFilesDir & "\", "Exe File (*.exe)", 3)
If @error Then
    ConsoleWrite("No select" & @CRLF)
Else
ConsoleWrite("Ok. select" & @CRLF)
EndIf

$RunCount = 2

For $i = 1 To $RunCount
$aRunw = RunWait($aOpenFiles)
Sleep(500)
ProcessWaitClose($aRunw)
Sleep(100)
Next

 

Edited by youtuber

Share this post


Link to post
Share on other sites
jdelaney

RunWait returns the exit code, not the PID.  You just need that on it's own, without the sleeps or ProcessWaitClose...or change RunWait to Run.  Some processes also spawn additional processes, so you might have to get, and then wait, for that PID, but that's probably not the case here.

Edited by jdelaney
  • Like 1

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
youtuber

Better thanks

$aOpenFiles = FileOpenDialog("", @DesktopDir & "\", "Exe File (*.exe)", 3)
If @error Then
    ConsoleWrite("No select" & @CRLF)
Else
ConsoleWrite("Ok. select" & @CRLF)
EndIf

$RunCount = 2

For $i = 1 To $RunCount
$aRunw = Run($aOpenFiles)
$aProgressClose = ProcessWait($aRunw)
Sleep(5000)
$aProgressClose2 = ProcessClose($aProgressClose)
Next

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×