Jump to content

Installing multiple programs


 Share

Recommended Posts

Hi all,

I am trying to use autoit to install multiple applications, one after the other.

A problem I am having is that after I've installed Adobe Acrobat 9.0 , my script then opens the program and makes a few changes to settings. While this part of the script is running, the next program starts installing before acrobat is finished.

Any suggestions would be appreciated.

Link to comment
Share on other sites

Here is the first few lines from the master installer script.

; Install AVG 9
#include "C:\installfiles\avg\install.au3"
sleep(2000)

; Install Acrobat
#include "C:\installfiles\AcrobatReader\install.au3"
sleep(2000)

; Install CCleaner
#include "C:\installfiles\CClearner\install.au3"
sleep(2000)

Here's the code from the Adobe Reader script.

run("C:\installfiles\AcrobatReader\AdbeRdr920_en_US.exe")

WinWaitActive("Adobe Reader 9.2 - Setup","Click Next to install to this folder")
send("!n")
WinWaitActive("Adobe Reader 9.2 - Setup","If you want to review or change any of your installation")
send("!i")
WinWaitActive("Adobe Reader 9.2 - Setup","Setup has successfully installed Adobe Reader 9.2")
send("!f")

; Start Acrobat, Accept EULA and close

run("C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe")
WinWaitActive("Adobe Reader - License Agreement","Press the Accept button to agree to the License Agreement")
ControlClick("Adobe Reader - License Agreement","Press the Accept button to agree to the License Agreement",1)
WinWaitActive("Adobe Reader","")
send("!{F4}")

And here is the code from the next program's script.

Run('C:\installfiles\CClearner\ccsetup228.exe')

WinWait("Installer Language","Please select a lang")
If Not WinActive("Installer Language","Please select a lang") Then WinActivate("Installer Language","Please select a lang")
WinWaitActive("Installer Language","Please select a lang")
Send("{ENTER}")
WinWait("CCleaner v2.28 Setup","Welcome to the CClea")
If Not WinActive("CCleaner v2.28 Setup","Welcome to the CClea") Then WinActivate("CCleaner v2.28 Setup","Welcome to the CClea")
WinWaitActive("CCleaner v2.28 Setup","Welcome to the CClea")
Send("{ALTDOWN}n{ALTUP}")
WinWait("CCleaner v2.28 Setup ","Please review the li")
If Not WinActive("CCleaner v2.28 Setup ","Please review the li") Then WinActivate("CCleaner v2.28 Setup ","Please review the li")
WinWaitActive("CCleaner v2.28 Setup ","Please review the li")
Send("{ALTDOWN}a{ALTUP}")
WinWait("CCleaner v2.28 Setup ","Choose Install Locat")
If Not WinActive("CCleaner v2.28 Setup ","Choose Install Locat") Then WinActivate("CCleaner v2.28 Setup ","Choose Install Locat")
WinWaitActive("CCleaner v2.28 Setup ","Choose Install Locat")
Send("{ALTDOWN}n{ALTUP}")
WinWait("CCleaner v2.28 Setup","Select any additiona")
If Not WinActive("CCleaner v2.28 Setup","Select any additiona") Then WinActivate("CCleaner v2.28 Setup","Select any additiona")
WinWaitActive("CCleaner v2.28 Setup","Select any additiona")
Send("{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{TAB}{SPACE}{ALTDOWN}i{ALTUP}")
WinWait("CCleaner v2.28 Setup ","Completing the CClea")
If Not WinActive("CCleaner v2.28 Setup ","Completing the CClea") Then WinActivate("CCleaner v2.28 Setup ","Completing the CClea")
WinWaitActive("CCleaner v2.28 Setup ","Completing the CClea")
Send("{SPACE}{ALTDOWN}f{ALTUP}")
Link to comment
Share on other sites

Welcome KluYa,

I guess your question is how to allow only 1 installation at a time included within the same script?

Use ProcessWaitClose() to prevent your script from continuing until the process has finished.

Example:

$pid = Run('path\to\file1.exe')
; automation code
ProcessWaitClose($pid)

$pid = Run('path\to\file2.exe')
; automation code
ProcessWaitClose($pid)
Link to comment
Share on other sites

  • Moderators

Welcome KluYa,

I guess your question is how to allow only 1 installation at a time included within the same script?

Use ProcessWaitClose() to prevent your script from continuing until the process has finished.

Example:

$pid = Run('path\to\file1.exe')
; automation code
ProcessWaitClose($pid)

$pid = Run('path\to\file2.exe')
; automation code
ProcessWaitClose($pid)

Or RunWait() if you want to avoid the extra line of code.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Well, as RunWait pauses execution while the program is running the ; automation code in Mhz' code wouldn't run when you use RunWait. So in that case it's not likely you want to use RunWait, or am I missing something :(?

Link to comment
Share on other sites

  • Moderators

Well, as RunWait pauses execution while the program is running the ; automation code in Mhz' code wouldn't run when you use RunWait. So in that case it's not likely you want to use RunWait, or am I missing something :(?

This is true. I generally use switches for silent installation, so I don't have any automation code. I over looked his comments in the code itself.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Ok, so The problem with Adobe Acrobat is fixed but now I'm having the same problem when installing .NET Framework 2.0.

Midway through installation of .NET Framework 2.0 the next program tries to install failing because something else is already installing.

Here is the script for .NET Framework 2.0

$pid = Run("C:\installfiles\dot net framework 2\dotnetfx2.exe")
WinWaitActive("Microsoft .NET Framework 2.0 Setup", "This wizard will guide you")
Send("!n")

WinWaitActive("Microsoft .NET Framework 2.0 Setup", "End-User License Agreement")
Send("!a")
Send("!i")

WinWaitActive("Microsoft .NET Framework 2.0 Setup", "It is highly recommended that you download")
Send("!f")
if ProcessExists($pid) Then
    Do
    ProcessClose($pid)
    Until ProcessWaitClose($pid)
EndIf
ProcessWaitClose($pid)

Part of the main script which calls the other ones.

; Install Dot Net 2.0
#include "C:\installfiles\dot net framework 2\install.au3"
sleep(2000)

; Installing Dot Net 3.5 last because it needs a reboot
; Install Dot Net 3.5
#include "C:\installfiles\dot net framework 3.5\install.au3"
sleep(2000)

The next script after .NET Framework 2.0

$pid = Run("C:\installfiles\dot net framework 3.5\dotnetfx35.exe")

$title = "Microsoft .NET Framework 3.5 SP1 Setup"

$visibletext = "Welcome to Setup"
WinWait($title,$visibletext)
If Not WinActive($title,$visibletext) Then WinActivate($title,$visibletext)
WinWaitActive($title,$visibletext)
Send("{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{SPACE}{ALTDOWN}i{ALTUP}")

$visibletext = "Microsoft .NET Framework 3.5 SP1 has been installed successfully."
WinWait($title,$visibletext)
If Not WinActive($title,$visibletext) Then WinActivate($title,$visibletext)
WinWaitActive($title,$visibletext)
Send("!x")

$visibletext = "&Restart Now"
WinWait($title,$visibletext)
If Not WinActive($title,$visibletext) Then WinActivate($title,$visibletext)
WinWaitActive($title,$visibletext)
Send("!l")

WinWaitActive("Microsoft .NET Framework 3.5 SP1 Setup", "Setup Complete")
Send("!x")
if ProcessExists($pid) Then
    Do
    ProcessClose($pid)
    Until ProcessWaitClose($pid)
EndIf
ProcessWaitClose($pid)

The problem definitely isn't the next script, as I've tried calling other installers after .NET 2.0

Link to comment
Share on other sites

Ok, so The problem with Adobe Acrobat is fixed but now I'm having the same problem when installing .NET Framework 2.0.

Midway through installation of .NET Framework 2.0 the next program tries to install failing because something else is already installing.

Here is the script for .NET Framework 2.0

DotNet 3.5 includes DotNet 2.0 so no need to install DotNet 2.0 from another installer. It is more convenient to use switches with DotNet as no options exist that switches can not handle.

These switches used should hopefully help to make it easier to install the programs. I do not use AVG or Adobe Reader so cannot verify what my searches found. You may want to check out Identify Installer in SendToA3X for finding switches for any other installers that you may have.

; in C:\installfiles\avg\install.au3
RunWait('"' & @ScriptDir & '\avg_free_stf_en_90_707a1765.exe" ' & _
        '/PROGRESSONLY /NOSTART /DISABLE_SCAN /NOAVGTOOLBAR ' & _
        '/REMOVE_FEATURE fea_AVG_SafeSurf /REMOVE_FEATURE fea_AVG_SafeSearch')

; in C:\installfiles\AcrobatReader\install.au3
RunWait('"' & @ScriptDir & '\AdbeRdr920_en_US.exe" /sAll')

; in C:\installfiles\CClearner\install.au3
RunWait('"' & @ScriptDir & '\ccsetup229_slim.exe" /S')

; in C:\installfiles\dot net framework 3.5\install.au3
RunWait('"' & @ScriptDir & '\dotnetfx35.exe" /qb /norestart')

Oh, if you have not already got it, get the slim CCleaner from the other builds section of the download page here. It has no spyware.

if ProcessExists($pid) Then
    Do
    ProcessClose($pid)
    Until ProcessWaitClose($pid)
EndIf
ProcessWaitClose($pid)

The code above may cause problems. Best to work with the install rather then against it. MSIexec can be temperamental so take care when using "ProcessClose($pid)" . The loop would also not loop as "Until ProcessWaitClose($pid)" blocks until the process is closed so instead use "Until Not ProcessExists($pid)" . I would probably only use "ProcessWaitClose($pid)" if I were to not use the switches previously mentioned.
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...