phaze424 Posted May 10, 2008 Posted May 10, 2008 (edited) I considered putting this on the bug reports board, but it's more likely that I'm doing something wrong, so here goes. I'm trying to write a seemingly simple wrapper program for a command-line program, but for some reason this doesn't work: Global $PID = Run(@ScriptDir & "\someDirectory\someApp.exe > aTextFile.txt", @ScriptDir, @SW_HIDE) ; Do some stuff ProcessClose($PID) The process simply isn't killed. Of course, ProcessClose() has no return value (1 every time) and doesn't set @Error, so I don't really know what's going on. Any insights? Edited May 10, 2008 by phaze424
botanic Posted May 10, 2008 Posted May 10, 2008 thats not how you get the pid global $PID Run(@ScriptDir & "\someDirectory\someApp.exe > aTextFile.txt", @ScriptDir, @SW_HIDE) $PID = ProcessExists ( "someApp.exe" ) ; Do some stuff ProcessClose($PID)
Dougiefresh Posted May 10, 2008 Posted May 10, 2008 thats not how you get the pid global $PID Run(@ScriptDir & "\someDirectory\someApp.exe > aTextFile.txt", @ScriptDir, @SW_HIDE) $PID = ProcessExists ( "someApp.exe" ) ; Do some stuff ProcessClose($PID)Funny... AutoIt help file says that the return value of Run is the PID of the process that was launched.
botanic Posted May 10, 2008 Posted May 10, 2008 (edited) i dunno ive never done it that way I guess there are issues EDIT: Global $PID $PID = Run(@ScriptDir & "\someDirectory\someApp.exe > aTextFile.txt", @ScriptDir, @SW_HIDE) ; Do some stuff ProcessClose($PID) Prolly cant be used in a Global? Maby? EDIT2: NOTE: I personally don't like to declare stuff on the same line as it is set to a global, if that is the issue then you'll see my reasoning for that practice Edited May 10, 2008 by botanic
Generator Posted May 10, 2008 Posted May 10, 2008 (edited) This works $PID=Run("notepad.exe") ProcessClose($PID) Edit: Try changing the flag parameter. Edited May 10, 2008 by Generator
botanic Posted May 10, 2008 Posted May 10, 2008 im looking at it the "> aTextFile.txt" could very well be the culprit
ResNullius Posted May 10, 2008 Posted May 10, 2008 I considered putting this on the bug reports board, but it's more likely that I'm doing something wrong, so here goes. I'm trying to write a seemingly simple wrapper program for a command-line program, but for some reason this doesn't work: Global $PID = Run(@ScriptDir & "\someDirectory\someApp.exe > aTextFile.txt", @ScriptDir, @SW_HIDE) ; Do some stuff ProcessClose($PID)oÝ÷ Ù8^¦ºzË,jeÊ+'ßÛdY^tçÜ¢êìxúèqë, Z,z¬Þ¶ê罩n{W¯z¼g×hzÉ÷öÛ´J뢻(!Ú'ßÛky©eÊIèÃZ·l§À(§²(!¶Ïêº^"ËayÊ&©Ý)ÞjZrÛ¢)àÝý²:N¨+h®Ø^²Özâ¶Úòjëh×6Run(@COMPSPEC & " /k " & @ScriptDir & "\someDirectory\someApp.exe > aTextFile.txt", @ScriptDir, @SW_SHOW) This will leave the command prompt open until you explicitly exit it. Also, you have the working dir set to @Scriptdir, but the command line executable is located in a subdirectory of that. Some command line programs need the working dir to be the same as their location.
phaze424 Posted May 10, 2008 Author Posted May 10, 2008 (edited) thats not how you get the pid global $PID Run(@ScriptDir & "\someDirectory\someApp.exe > aTextFile.txt", @ScriptDir, @SW_HIDE) $PID = ProcessExists ( "someApp.exe" ) ; Do some stuff ProcessClose($PID)ƒoÝŠ÷ Ú«¨µéÚ™ Thanks to Craig Peacock's process.exe for helping me figure this out. Edited May 10, 2008 by phaze424
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