Jump to content

RunWait ProcessWaitClose issues


 Share

Recommended Posts

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
Link to comment
Share on other sites

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
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.
Link to comment
Share on other sites

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

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...