Sign in to follow this  
Followers 0
phaze424

ProcessClose() not working with a PID

8 posts in this topic

#1 ·  Posted (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 by phaze424

Share this post


Link to post
Share on other sites



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.

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by botanic

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

This works

$PID=Run("notepad.exe")
ProcessClose($PID)

Edit: Try changing the flag parameter.

Edited by Generator

Share this post


Link to post
Share on other sites

im looking at it the "> aTextFile.txt" could very well be the culprit

Share this post


Link to post
Share on other sites

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.

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
Sign in to follow this  
Followers 0