Jump to content

Using Run()


Recommended Posts

Newbie alert.

So I just started using autoit about 4 days ago.

I'm trying to write a script that runs 19 .exe installers for our application, one after the other.

So far I have it working perfectly, but I have to use a .bat file to call each .exe.

The reason is, when I call them in autoit, it runs the next one when it does the last step for the previous one, but the previous

one wasn't actually done. This causes a crash. These .exe's are application updates and I'm guessing they are still registering .dll's or something in the background even when the installer has disappeared.

If I use a .bat that looks like this:

CMD /c installupdate1.exe

CMD /c installupdate2.exe

CMD /c installupdate3.exe etc....

then windows won't open the next command until it is actually done.

How can I emulate this in autoit and eliminate the .bat script?

And just a heads up, adding a timer won't work as the pc's these are being loaded on vary from p3-866's with 256mb ram, all the way to dual cpu 2gb ram systems. I don't want to slow the process by 45 seconds just to keep the slow systems happy.

Thanks for the help!

Link to comment
Share on other sites

Try using RunWait() instead of Run. RunWait() will wait for the process to end before continuing with the script.

- The Kandie Man ;-)

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
Share on other sites

RunWait ( )?

Edit: Sorry Kandie man did not see you post must have post at the same time....

Edited by flip209

" I haven't failed. I've just found 10,000 ways that won't work." Thomas Edison "You cannot help men permanently by doing for them what they could and should do for themselves." Abraham Lincoln

Link to comment
Share on other sites

RunWait ( )?

Edit: Sorry Kandie man did not see you post must have post at the same time....

Well guys I tried that, problem is, I'm using autoit to fill in a cd key and user information, so I can't let autoit wait.

If it was easy I wouldn't ask LOL :)

I hope it's easy though!

Link to comment
Share on other sites

Could you post the code to look at?

Edited by flip209

" I haven't failed. I've just found 10,000 ways that won't work." Thomas Edison "You cannot help men permanently by doing for them what they could and should do for themselves." Abraham Lincoln

Link to comment
Share on other sites

Could you the code to look at?

Yes I can, though I'll have to strip out some stuff as I deal with some confidential info, so it may not by syntactically correct.

;Turn on progress bar.
ProgressOn("Automated updates Install", "Installing...", 0, 5)

;Execute dos batch file.
Run("ChainedUpdateScript.bat")

;Fixes 1 - 19
WinWaitActive("updatefix", "&Next >")
Send("!n")
WinWaitActive("updatefix", "Collect User Information")
Send(@TAB)
Send(@TAB)
Send("xxxxxx-xxxxxx-xxxxxx-xxxxxx-xxxxxx")
Send("!n")
WinWaitActive("Registration Confirmation")
Send(@TAB)
Send(@TAB)
Send(@CR)
WinWaitActive("updatefix", "Click Browse to point")
Send("!n")
WinWaitActive("updatefix", "Setup has enough information")
Send("!n")
WinWaitActive("updatefix", "Finish")
Send("{DOWN}")
Send(@CR)
WinSetState("C:\WINDOWS\system32\cmd.exe","", @SW_MINIMIZE)
;Increment progress bar.
ProgressSet( 5.26,5.26 & "%")

I do this about 19 times for different updates that the company releases.

the .bat file looks something like this:

CMD /C "updatefix1.exe"

CMD /C "updatefix2.exe"

CMD /C "updatefix3.exe"

all the way to 19

Link to comment
Share on other sites

Ok, you run the .bat, and run the install walkthrough. do have to run the updatefix1.exe throught the batch or could you do a:

$find = filefindfirstfile("where the .exe's are")

then loop through the exe to run each update sepreatly?

" I haven't failed. I've just found 10,000 ways that won't work." Thomas Edison "You cannot help men permanently by doing for them what they could and should do for themselves." Abraham Lincoln

Link to comment
Share on other sites

some thing like this:

; Shows the filenames of all files in the current directory.

$search = FileFindFirstFile("*.*")

; Check if the search was successful

If $search = -1 Then

MsgBox(0, "Error", "No files/directories matched the search pattern")

Exit

EndIf

While 1

$file = FileFindNextFile($search)

If @error Then ExitLoop

;Fixes 1 - 19

WinWaitActive("updatefix", "&Next >")

Send("!n")

WinWaitActive("updatefix", "Collect User Information")

Send(@TAB)

Send(@TAB)

Send("xxxxxx-xxxxxx-xxxxxx-xxxxxx-xxxxxx")

Send("!n")

WinWaitActive("Registration Confirmation")

Send(@TAB)

Send(@TAB)

Send(@CR)

WinWaitActive("updatefix", "Click Browse to point")

Send("!n")

WinWaitActive("updatefix", "Setup has enough information")

Send("!n")

WinWaitActive("updatefix", "Finish")

Send("{DOWN}")

Send(@CR)

WEnd

; Close the search handle

FileClose($search)

Almost directly out of the help file *GOD Bless that help file*

Edited by flip209

" I haven't failed. I've just found 10,000 ways that won't work." Thomas Edison "You cannot help men permanently by doing for them what they could and should do for themselves." Abraham Lincoln

Link to comment
Share on other sites

Ok, then you would do this:

Dim $i_PID 
$i_PID = Run("Dinstallupdate1.exe")

;~ Do the Automation with the windows here
;~ Once done with the automation of this particular installer do the following

While ProcessExists($i_PID)
    sleep(100)
Wend

$i_PID = Run("Dinstallupdate2.exe")

;~ Do the Automation with the windows here
;~ Once done with the automation of this particular installer do the following


While ProcessExists($i_PID)
    sleep(100)
Wend

$i_PID = Run("Dinstallupdate3.exe")

;~ Do the Automation with the windows here
;~ Once done with the automation of this particular installer do the following

While ProcessExists($i_PID)
    sleep(100)
Wend

;~ Continue this until you have run all the updates and automated all the windows.

- The Kandie Man ;-)

Edited by The Kandie Man

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
Share on other sites

Ok, then you would do this:

Dim $i_PID 
$i_PID = Run("Dinstallupdate1.exe")

;~ Do the Automation with the windows here
;~ Once done with the automation of this particular installer do the following

While ProcessExists($i_PID)
    sleep(100)
Wend

$i_PID = Run("Dinstallupdate2.exe")

;~ Do the Automation with the windows here
;~ Once done with the automation of this particular installer do the following
While ProcessExists($i_PID)
    sleep(100)
Wend

$i_PID = Run("Dinstallupdate3.exe")

;~ Do the Automation with the windows here
;~ Once done with the automation of this particular installer do the following

While ProcessExists($i_PID)
    sleep(100)
Wend

;~ Continue this until you have run all the updates and automated all the windows.

- The Kandie Man ;-)

Hey that might work so you would have me locate the process id and wait until it's done. I will try that. I have to head home for the week, and it's a 3 day weekend so I won't get to it until tuesday most likely, but I think that should work!

I'll post my results.

Link to comment
Share on other sites

It should work and I wish you the best of luck. Have a nice Labor Day Weekend too.

- The Kandie Man ;-)

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...