Sign in to follow this  
Followers 0
Guest Poul

Getting process ID from launched DOS app

4 posts in this topic

#1 ·  Posted (edited)

Hi!

I am using AutoIt to automate some CVS work, but have run into a problem regarding processes.

In my script I launch a DOS application (cvs.exe) using the Run(@ComSpec & " /c " & $myCommand) syntax. This works mighty fine. However, when running lenghty operations I want to allow the user to break the operation from a GUI. As the DOS window is hidden and the output is being piped to a file, I believe the right (but pretty brutal, though) way to do this, is to simply kill the cvs.exe process. However, the process ID returned by the Run command is that of cmd.exe and not cvs.exe -- and killing the cmd.exe process does not take cvs.exe down with it.

So, how do I get the process ID of my cvs process? And just to complicate matters, I want to be able to have more cvs.exe processes running at the same time.

/ Thanks in advance, Poul.

Edited by Poul

Share this post


Link to post
Share on other sites



Hi!

I am using AutoIt to automate some CVS work, but have run into a problem regarding processes.

In my script I launch a DOS application (cvs.exe) using the Run(@ComSpec & " /c " & $myCommand) syntax. This works mighty fine. However, when running lenghty operations I want to allow the user to break the operation from a GUI. As the DOS window is hidden and the output is being piped to a file, I believe the right (but pretty brutal, though) way to do this, is to simply kill the cvs.exe process. However, the process ID returned by the Run command is that of cmd.exe and not cvs.exe -- and killing the cmd.exe process does not take cvs.exe down with it.

So, how do I get the process ID of my cvs process? And just to complicate matters, I want to be able to have more cvs.exe processes running at the same time.

/ Thanks in advance, Poul.

<{POST_SNAPBACK}>

What about doing a RUN("PATH2CVS\cvs.exe params" ) instead of using the @Comspec ?

That should return the CVS.EXE ProcessID...


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Ah sorry, I forgot to mention that I use '>' to pipe the output from the cvs command to a file for later presentation. I read somewhere that you HAVE to use @ComSpec to use this pipe functionality?!

Edited by Poul

Share this post


Link to post
Share on other sites

Ah sorry, I forgot to mention that I use '>' to pipe the output from the cvs command to a file for later presentation. I read somewhere that you HAVE to use @ComSpec to use this pipe functionality?!

<{POST_SNAPBACK}>

Yes, you have to as piping is a function from the command line interpreter. But the drawback is that you don't start the cvs.exe process itself and as such have no secure way to get the PID of the process.

A workaround that's a bit dangerous is to use ProcessExists('cvs.exe') to get the PID. But it's possible that it returns the PID of a different process than the one you want to as there might be more than one cvs.exe process running.

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