youtuber Posted December 2, 2017 Share Posted December 2, 2017 (edited) 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 December 2, 2017 by youtuber Link to comment Share on other sites More sharing options...
jdelaney Posted December 2, 2017 Share Posted December 2, 2017 (edited) 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 December 2, 2017 by jdelaney youtuber 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. Link to comment Share on other sites More sharing options...
youtuber Posted December 2, 2017 Author Share Posted December 2, 2017 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now