Impulse08 Posted February 9, 2007 Share Posted February 9, 2007 Hi all, What I want to do: Basically I wrote a program that can run multiple programs in sequential order. Runs prog1, prog1 finishes then runs prog2 and so on and so on. Now I want to add the functionality to run each program on multiple computers. For this I'm going to use psexec. (unless someone has a better idea?) What I'm trying to do: For $j = 0 to $countComputer - 1 For $i = 0 To $count - 1 runOnComp($compListArray[$j], $progPath[$i], $progName[$i]) Next Next func runOnComp(....) Runs prog1 on comp1 and waits for it to finish before running prog2 end func I want to launch each program in the order it needs to be on each computer, but I want to be able to do this in parallel, Here's a possible scenario I want to do: i.e. comp1 is running prog1 while comp2 is running prog1 comp1 finishes prog1 and start prog2 comp2 still is running prog1 so it continues this comp1 finishes prog2 and runs prog3 comp2 finish prog1 and start prog2 comp1 finishes prog3 and it is done comp2 finishes prog2 and starts prog3 comp2 finishes prog3 and it is done program complete Anyone have any idea on how to do something like this? Can I somehow launch each computer as it's own thread of a function? Any help would be greatly appreciated!!! Please let me know if you need me to clarify anything. -- If the apocalypse comes... beep me. Link to comment Share on other sites More sharing options...
PaulIA Posted February 10, 2007 Share Posted February 10, 2007 You can use the CreateProcess API to spawn a new process (with optional waiting). It's implemented in the A3LWinAPI module of Auto3Lib if you need an example of how to implement the API call. Auto3Lib: A library of over 1200 functions for AutoIt Link to comment Share on other sites More sharing options...
Impulse08 Posted February 12, 2007 Author Share Posted February 12, 2007 You can use the CreateProcess API to spawn a new process (with optional waiting). It's implemented in the A3LWinAPI module of Auto3Lib if you need an example of how to implement the API call. Thanks. I'll definitely have to check that out. (I am right at the moment). Another problem of this I'm trying to work out is to continue running another program on a computer that has finished its first. It's more of a how do I program this correctly. I have an array of programs to run: $progPath[$i], $progNameRun[$i] As well as an array of the number of computers to run on $compListArray[$i] My current script can run multiple programs in sequence (waiting for one program to end before calling the next), using: While ProcessExists($pID) Sleep(5000) WEnd How do I incorporate this logic where programs have to be run in sequence, but on multiple computers now? The case I'm wondering about is what if one computer finishes a program before the others. I don't want to start running the 2nd program on the other computers before they finish the 1st, but it'd also be nice if the 1st computer could go on to the 2nd program without waiting. Any ideas programming-wise on how to accomplish this? Thanks. -- If the apocalypse comes... beep me. Link to comment Share on other sites More sharing options...
PaulIA Posted February 12, 2007 Share Posted February 12, 2007 Thanks. I'll definitely have to check that out. (I am right at the moment). Another problem of this I'm trying to work out is to continue running another program on a computer that has finished its first. It's more of a how do I program this correctly. I have an array of programs to run: $progPath[$i], $progNameRun[$i] As well as an array of the number of computers to run on $compListArray[$i] My current script can run multiple programs in sequence (waiting for one program to end before calling the next), using: While ProcessExists($pID) Sleep(5000) WEnd How do I incorporate this logic where programs have to be run in sequence, but on multiple computers now? The case I'm wondering about is what if one computer finishes a program before the others. I don't want to start running the 2nd program on the other computers before they finish the 1st, but it'd also be nice if the 1st computer could go on to the 2nd program without waiting. Any ideas programming-wise on how to accomplish this? Thanks.Here's some skeleton code to show proof of concept: Global $aComputers[64][3] ; 0=Computer Info, 1=ProcessID, 2=Program Index Global $aPrograms [64] ; Fully qualified list of programs to be executed Func RunPrograms() Local $iI for $iI = 1 to $aComputers[0][0] ; See if computer is running a program if $aComputers[$iI][1] <> 0 then ; See if process still exists if not ProcessExists($aComputers[$iI][1]) then ; Current program is done, advance to next program StartProgram($iI) endif else ; Start initial program StartProgram($iI) endif Sleep(100) next EndFunc Func StartProgram($iComputer) Local $iIndex, $hProcessID ; Check to see if all programs have been run for this computer $iIndex = $aComputers[$iComputer][2] + 1 if $iIndex > $aPrograms[0] then Return ; Start next program using CreateProcess ; Call CreateProcess with proper parameters from $aPrograms[$iIndex] ; Get process ID into $hProcessID ; Update computer program index $aComputers[$iComputer][1] = $hProcessID $aComputers[$iComputer][2] = $iIndex EndFunc Auto3Lib: A library of over 1200 functions for AutoIt 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