Sign in to follow this  
Followers 0
SHAHRAM

Run multiple processes and wait for them

7 posts in this topic

Hello,

I am using "PSEXEC" to run some software on a couple of remote computers at the same time and know when they are closed so my application can continue,

My problem is if I used "RunWait", it goes from one client to another waiting for each to finish before going to the next

and if I used "Run", I can execute them simultaneously but my application cant wait for them,

so my question is, is it possible to run a couple of "RunWait"s at the same time.

Share this post


Link to post
Share on other sites



Run() returns the PIDs, and you can use those to track when the processes close.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Run() returns the PIDs, and you can use those to track when the processes close.

:)

thanx, I have been playing with it a little bit,

running psexec is usually like "@ComSpec & ' /c psexec.exe ...'"

so Run() returns pid of the cmd.exe on the local computer and not the remote process,

but at the end I was able to use the "-d" switch on psexec which is "Don't wait for application to terminate" and then use RunWait() on it,

this ways, psexec returns the process id as %errorlevel% which RunWait() catches,

then using similar concept, process id can be passed to "PSLIST", and from the returned errorlevel I can see if the process was closed or not.

Share this post


Link to post
Share on other sites

The @COMSPEC shell is only required to run native shell commands (i.e. DIR). You should be able to run PSEXEC.exe directly without the @COMSPEC.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Well, its working this way for, though I dont think Run() would give me the PID of the Remote Process if psexec is executed directly.

RunWait() is very convenient that it waits for psexec to finish with running the remote program and then catches the PID which was returned as ERRORLEVEL (exit code),

There is one problem with RunWait() though in this case,

Is there any ways to capture the output of psexec from RunWait() inside autoit???????????????????

(right now the only thing I can do is to output it to a file ("2> x.log") and read the content of that file)

PS.

Explanation of why it is needed

when psexec fails, it returns a windows error code instead of PID, for example "1326" for logon failure,

but there is no way for me to know if this number is a PID or an error code,

If I could get STDOUT of RunWait() the problem would be solved

(I can look a word that identifies it as success eg "started", otherwise treat it as failure)

But it seems "$STDERR_CHILD / $STDOUT_CHILD" only work with streams coming from Run() and I cant find any functions that captures output of RunWait(),

Share this post


Link to post
Share on other sites

......

Is there any ways to capture the output of psexec from RunWait() inside autoit???????????????????

(right now the only thing I can do is to output it to a file ("2> x.log") and read the content of that file)

......

use RemCom.exe instead of psexec....see here:

I used it and it works well

bye


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

You can always use TCPIP connections...or, have the called station create a text file of the current status on a shared drive, and have your caller check periodically for updates/completion.


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.

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