Jump to content

Child process running command line exe's ? With error handling?

Recommended Posts

Hi there,

New to AutoIT so a warm hello to all of you :-)

I've written a script with a GUI and 3 "major" buttons : X, Y and Z. Which happen to correspond to my 3 DVD-drives...
As I want to backup all my old CD's, X should start a process on the X:-drive, Y on the Y: and so on... Easy peasy...
Each process is as follows :
* copy files (robocopy / xcopy)
* create a checksum on those files (fsum)
* verify the contents of the original CD with the files copied to the harddisk (csdiff)

Robocopy / fsum and csdiff are all "cli-operated" so each CD takes about 5 to 10 minutes before being "ready".

Is there a way in AutoIT that can create such a "child" process? Launch a "block" of three files and goes back to the main? So I can press the Y: button while X: is busy?

Hope everything is clear with the above :-)

Share this post

Link to post
Share on other sites

You will need to clarify a little. A lot would be better, but a little might get you understood.

For example, how are you starting this command? etcetera...

Share this post

Link to post
Share on other sites

Morning John1,

Perhaps I do indeed :)   My pleasure so here it goes :

First up : the rudimentary GUI :


The red string is something that's being kept in the registry and can be changed with the EditLoc button (that works already)

The 3 X/Y/Z buttons are triggered as follows :

Case $XButton

Case $YButton

Case $ZButton


And the CopyFromDrive is the following function :

Func CopyFromDrive($DriveSelector)
   ; *********** DRIVE CLOSE BEFORE STARTING ***********
   CDROM_Close ($DriveSelector)
   GUICtrlSetData ($StatusLabel_A, "Drive : " & $DriveSelector)
   ; *********** CREATE DIRECTORIES ***********
      For $Count_Thousands = 0 To 9
         If $Count_Hundreds = 9 Then $Count_Hundreds = 0
         If $Count_Singles = 9 Then $Count_Singles = 0
         For $Count_Hundreds = 0 To 9
            If $Count_Singles = 9 Then $Count_Singles = 0
            For $Count_Singles = 0 To 9
                  If FileExists ($TempVariable & "\" & $Count_Thousands & $Count_Hundreds & $Count_Singles) Then
                     DirCreate ($TempVariable & "\" & $Count_Thousands & $Count_Hundreds & $Count_Singles)
                     $Count_Thousands = 9
                     $Count_Hundreds = 9
                     $Count_Singles = 9

   ; *********** COPY DATA FROM CD ***********
   Run("xcopy " & $DriveSelector & "\*.* " & $LocVariable & " /E /S", "", @SW_HIDE)
   GUICtrlSetData ($StatusLabel_A, "Error : " & @error)
   ; *********** CREATE A CHECKSUM **********
   Run("x:\tools\CLI\fsum", "", @SW_HIDE)   ; placeholder! options to be added
   ; *********** COMPARE SOURCE WITH DESTINATION **********
   Run("x:\tools\CLI\csdiff", "", @SW_HIDE) ; placeholder! options to be added
   ; *********** OPEN DRIVE, READY FOR THE NEXT ONE ***********
   CDROM_Open ($DriveSelector)                                              

So : I insert a CD into the corresponding tray, I push the corresponding button and what happens next is  :

1. the tray is closed
2. the destination directory is created (going from 000 to 999)
3. the data is copied from the CD
4. a MD5 checksum is created on the destination (the fsum line)
5. the data is one last time compared against the source
6. the tray is opened again

I'll do my best to explain this : my issue is that the above works as a "single" process : you push the X: button eg, I wait for 10 minutes as it goes through the function and when it's done, I can push the Y: button. 
But I would like to know if this can be made as a "multi" process : I push the X: button and while it's doing its thing, I can also push the Y: button.

Hmm, is it apparent to see that I'm new to this? :)




Share this post

Link to post
Share on other sites

I initially thought I had it running :

First I thought Oh my... Oh my... :>

The shame... The horror... After posting the above, I thought : who said I can't push the Y: button? Perhaps it's already functional as it is, so I changed :

Case $XButton

Case $YButton

Case $ZButton


And with this function :

Func PingWait()
   Run ("cmd /c PING -n 60 >NUL 2>&1 || PING ::1 -n 60 >NUL 2>&1")

And yes, it worked as expected :>:>:>:>

So.. It was a non-issue after all :drool:

thanks though!


And again shortly after : I realized I'm still stuck and I misinterpreted the way the Run() works :

Added some extra testing to be sure (2 Statuslabels that were updated on the GUI) and noticed that the labels were updated immediately (while the pings were still running). Changed the Run() to Runwait() as follows :

Func WaitPing10()
   RunWait ("cmd /c PING -n 10 >NUL 2>&1 || PING ::1 -n 10 >NUL 2>&1")
   GUICtrlSetData ($StatusLabel_A, "10 DONE")

Func WaitPing60()
   RunWait ("cmd /c PING -n 60 >NUL 2>&1 || PING ::1 -n 60 >NUL 2>&1")
   GUICtrlSetData ($StatusLabel_B, "60 DONE")

Tied the WaitPing10 to the Y-button, the WaitPing60 to the Z-button and yes, pressing the Y-button triggered the first ping but pressing the Z-button (while the Y-button process was still running) did nothing...

So... Any suggestions? :)


Edited by echdareez
Too hasty

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

  • Create New...