Jump to content

the guide of "Using autoit for silent install"


master_mtz

Recommended Posts

hi all , i am making this little guide to help making autoit scripts , to avoid the troubles of finding switches and so on .....

==============================================

here we go .....

=============================================

-----------------------

what is an Autoit Script

------------------------

it is a simple script , made to do jobs automatically , u write down the script (the script is mainly a robot that will tell the system what to do ) , then compile it , the resulting exe will do what u specifed in the code each time the program runs,

----------------------------

What is the relation between Auto it and silent install:

---------------------------

simply , u wil make the installation go smoothly , without ur interaction , the script u make will do the job ..... u may see examples in this topic :

http://www.msfn.org/board/index.php?showtopic=20197

---------------------

OHH dear , shall i write scripts and think of coding

----------------------

Answer is , NO , u will see in this guide , how will we make scripts for silent installs without writing code.

------------------------

Why and when shall i use autoit for silent install ?

------------------------

when u don't find the silent switch u need , u are pushed to use the autoit method ..

==============NOW LET US GOOO!!!!================

firstly we need the program ,,, get it here

http://www.autoitscript.com/cgi-bin/getfil...it-v3-setup.exe

and we need the Scite tool , to use the script recorder::

Scite

---------

http://www.autoitscript.com/cgi-bin/getfil...iTe4AutoIt3.exe

install both programs ,,,

now go to :

Start >>programs>>autoit V3>>scite>>Script Writer

u will see this :

w6w_2005080100134718858b42885b3.gif

1- select the installation package which u r going to make the script for , it shall be an EXE which the script will call each time it runs ..........

2- make the check boxes , as made in the pic

3- click the "A" button

once we click the "A" button,the exe(which is the installation package) we specifed will run, and every movement we make on our pc using the keyboard will be recorded,

During the record of this code , Take care of :

1-Avoid Alt+tab, or navigating to othr windows

2- use " Alt+N" to choose "next" ، Alt+y to choose " Yes" , and so on ..

3- u may use the Tab button to navigate between buttons

After u completly installed the application , we have to stop the record operation by clicking the "A" button at the upper left of the screen , now u must see some code written like this ....

w6w_2005080100174818858ca371f74.gif

Now , we have to add little code to our app , to avoid hassles , and running same application again and again

-------------------------------------

$SF_1 = "app.exe"

If WinExists ( $SF_1 ) Then Exit

AutoItWinSetTitle ( $SF_1)

---------------------------------------

** u may ask , what is this attented for , the answer is , this code is just a safety measure during the testing period , i once used a script which don't have this code (or similiar) and a big trouble occourded , the compiled EXE kept running it self again and again , and at last , 101 process where running on my poor pc :no: , i used taskkill to

get rid of those processes and i succeded :thumbup

---------------------------------

replace app.exe by the installation package exe u selected when recording the script, now save the file near by ur EXE package as u see in the pic , then compile the script ....

w6w_200508010020101885861bedb64.gif

NOW all is done we have the compiled EXE , try running it now , u will see every thing in the setup going automatically

without ur interaction , once u test and find every thing working good , u may make a RARsfx which will have the compiled EXE to run after the extraction process

Edited by master_mtz
Link to comment
Share on other sites


great guide for n00bs....i started learning autoit in march of this year and i am already somewhat proficient at it. I think anyone interested in using autoit would be well served checking out this man's guide. it's a good intro to how powerful and easy autoit can be....

Link to comment
Share on other sites

@ MAVERICKS CHOICE

thx 4 ur reply

@ redfive19

well ,actually i made it for nooobs like me :D ....

not for professionals B)

and i wrote this simple guide cuz i didn't find any thing about autoit here excepting the autoit scripts collection :no:

at all ,

i thank u all guys for posting replies :thumbup

Link to comment
Share on other sites

Nice guide, master_mtz.

It is a good starting reference for noobs of AutoIt.

Scite4AutoIt3 has all the tools onboard for making AutoIt scripts as easy as possible. As a user may get to know some of the vast amount of inbuilt functions, then AutoItMacroGenerator could be used. This program is made for unattended installs in mind. AutoItMacroGenerator records as well. Some knowledge of the Control*() functions maybe needed to edit the final draft script created by AutoItMacroGenerator.

CMenu can create AutoIt scripts for silent installing. The thread is in this forum.

Certainly a nice range of tools, to help the user with creating installation scripts. :)

Link to comment
Share on other sites

I have been searching all over this forum to find a solution to installing applications that do not yet have a answer file or silent switch yet! In fact it was the main reason why I registered!

This is the answer, compact and easy... Master_mtz, you are my hero ;):P

Link to comment
Share on other sites

@ Railman5 and dirtwarrior

rhx 4 replying

@ neoandersom

really glad to be ur hero :thumbup:D

@ MHZ

well , if i had known about Cmenu before i would haven't written this guide :no :blushing:

Bu i think the guide is still helpful for beginners and noobs :) :rolleyes

Link to comment
Share on other sites

Thats an ok way of doing things :) , but I suggest learning AutoIT as its come in so much use for me, and not just for unattended installs.

I wrote this, the other day:

; Delete Registry Key, to make Start Menu alphabetically sorted
RegDelete("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder")

If ProcessExists("firefox.exe") Then
   MsgBox(0, "CleanScript Notice", "Firefox.exe is running, closing this message will kill the process")
   ProcessClose("firefox.exe")
Else
   MsgBox(48, "CleanScript Notice", "Firefox process not running", 5)
EndIf

; Open Firefox's profiles.ini in read only mode
$file = FileOpen(@AppDataDir & "\Mozilla\Firefox\profiles.ini", 0)

; Check the file is open and can be read
If $file = -1 Then
   MsgBox(0, "Error", "Unable to open file.")
   Exit
EndIf

; Read line 7 of that file, which will return the profile path we need.
$line = FileReadLine($file, 7)

; Trim the string from the left
$fetchedpath = StringTrimLeft($line, 14)

; Close the file
FileClose($file)

; Remove Firefox cache
DirRemove(@AppDataDir & "\Mozilla\Firefox\Profiles\" & $fetchedpath & "\Cache", 1)
DirRemove(@AppDataDir & "\Mozilla\Firefox\Profiles\" & $fetchedpath & "\Cache.Trash", 1)

; Delete users temporary files
FileDelete(@TempDir & "\*.*")
DirRemove(@TempDir, 1)

; Delete Firefox form and browser history
FileDelete(@AppDataDir & "\Mozilla\Firefox\Profiles\" & $fetchedpath & "\history.dat")
FileDelete(@AppDataDir & "\Mozilla\Firefox\Profiles\" & $fetchedpath & "\formhistory.dat")

; Search for all "fixed" drives
$var = DriveGetDrive( "fixed" )
If NOT @error Then
For $i = 1 to $var[0]
 $String = $var[$i]
 $Disk = StringTrimRight($String, 1)
 RunWait(@ComSpec & " /c " & "Diskeeper " & $Disk & " /b")
 TrayTip("CleanScript message:", "" & $var[$i] & " Drive defragmented", 7, 1)
Next
EndIf

; Write command to shutdown system, using RunOnceEx
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx", "TITLE", "REG_SZ", "Scheduled Shutdown")
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\001", "1", "REG_SZ", "Shutdown -s -t 10 -c ""Shutting down after cleaning system"" /f")

; Reboot the machine
#include <Process.au3>
$rc = _RunDos("shutdown -r -t 05")

Uses disk keeper to defrag my hard drives and cleans up my firefox browser and performs a boot optimisation, reboots and then shuts down the system.

Good to use when I wanna go to bed, just run it and turn off my monitor and let the system handle itself.

Link to comment
Share on other sites

@ MHZ

well , if i had known about Cmenu before i would haven't written this guide  :no :blushing:

Bu i think the guide is still helpful for beginners and noobs  :)  :rolleyes

Yes, it is good for the beginners. I did state that previously? I do mention also of other options that people may not be aware of. The first tool that I would think of is AutoMacroGenerator, if I wanted an application to record a automated gui install with AutoIt. I use CMenu to do up silent installation scripts. I would use Au3Record for manipulating items on the desktop, that only a keyboard and mouse can manage. So, each of the said tools, have a different purpose of their capabilites. If you want to use any of these options to do unattended installations, then that is ok by me.

There is a tutorial in the AutoIt help guide that shows you how to install Winzip. Once you have learnt to make use of the Win*() functions, and Send() etc. then you should have a look at the Control*() functions, as mentioned at the bottom of the page. Learning is about doing one thing at a time, so learning the primary functions 1st is a good way to go. So, this guide above is also a good place to start. But should be noted, as not the be all and end all of accomplishing installations with AutoIt. Once you can do installations manually written with AutoIt, then you should be able to do many more things with it. It is a very powerful language for scripting your everyday needs etc.

A simple and basic guide, is good for the newcomers of AutoIt. This guide fits that need. So, nice work again, master_mtz. ;)

Link to comment
Share on other sites

  • 6 months later...

After reading this post I am still a little unsure how you consider this a silent install. To me, a silent install is something that can be run without seeing any screens flash up and could be installed during computer startup. AutoIT seems to just hit the buttons that an end user would normally push and the screens still flash by. So if it has to see windows to hit buttons, it can't be done silently. Can you please explain to me how it would be done silently?

Jeff

Link to comment
Share on other sites

After reading this post I am still a little unsure how you consider this a silent install. To me, a silent install is something that can be run without seeing any screens flash up and could be installed during computer startup. AutoIT seems to just hit the buttons that an end user would normally push and the screens still flash by. So if it has to see windows to hit buttons, it can't be done silently. Can you please explain to me how it would be done silently?

Jeff

Because some programs cannot be installed silently. MusicMatch Jukebox and iTunes are two examples. What this does is allow an UNATTENDED installation of a program. Yes, the user still sees the screens fly by, but their interaction is not required to install the program. A silent installation is one that you describe: Minimal or non-existant indications that a program is being installed. Many programs can be installed like this, others can't.

The two terms are sometimes confused.

Link to comment
Share on other sites

thanks for this great and clear guide!

I downloaded crapcleaner 1.27 (http://www.ccleaner.com), updated just today, and i want to use autoit to get rid of the omnipresent yahoo toolbar bundled with it, and to set 2 more options in the standard setup. Following your guide and using the editor (to add the $SF_1 section), i get this autoit script (i use italian as default install language):

Opt("WinWaitDelay",100)
Opt("WinTitleMatchMode",4)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)

$SF_1 = "ccsetup127.exe"
If WinExists ( $SF_1 ) Then Exit
AutoItWinSetTitle ( $SF_1)
Run('ccsetup127.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("{TAB}{ENTER}")
WinWait("Installazione di CCleaner v1.27","Benvenuti nel progra")
If Not WinActive("Installazione di CCleaner v1.27","Benvenuti nel progra") Then WinActivate("Installazione di CCleaner v1.27","Benvenuti nel progra")
WinWaitActive("Installazione di CCleaner v1.27","Benvenuti nel progra")
Send("{ENTER}")
WinWait("Installazione di CCleaner v1.27 ","Prego leggere le con")
If Not WinActive("Installazione di CCleaner v1.27 ","Prego leggere le con") Then WinActivate("Installazione di CCleaner v1.27 ","Prego leggere le con")
WinWaitActive("Installazione di CCleaner v1.27 ","Prego leggere le con")
Send("{TAB}{TAB}{ENTER}")
WinWait("Installazione di CCleaner v1.27 ","Scelta della cartell")
If Not WinActive("Installazione di CCleaner v1.27 ","Scelta della cartell") Then WinActivate("Installazione di CCleaner v1.27 ","Scelta della cartell")
WinWaitActive("Installazione di CCleaner v1.27 ","Scelta della cartell")
Send("{TAB}{TAB}{TAB}{ENTER}")
WinWait("Installazione di CCleaner v1.27","Opzioni di Installaz")
If Not WinActive("Installazione di CCleaner v1.27","Opzioni di Installaz") Then WinActivate("Installazione di CCleaner v1.27","Opzioni di Installaz")
WinWaitActive("Installazione di CCleaner v1.27","Opzioni di Installaz")
Send("{DOWN}{DOWN}{SPACE}{DOWN}{DOWN}{SPACE}{TAB}{SPACE}{TAB}{TAB}{ENTER}")
WinWait("Installazione di CCleaner v1.27 ","Completamento dell'i")
If Not WinActive("Installazione di CCleaner v1.27 ","Completamento dell'i") Then WinActivate("Installazione di CCleaner v1.27 ","Completamento dell'i")
WinWaitActive("Installazione di CCleaner v1.27 ","Completamento dell'i")
Send("{ALTDOWN}f{ALTUP}")

After saving, using it from right click works perfectly, but when i compile it to exe, ccleaner setup remains on the last screen, waiting that someone press Finish... i tried with different keys (space, enter, alt-f, alt-f4, f), but no way: rclick-exec script works, but compiled exe remains on last screen... any help?

Link to comment
Share on other sites

After saving, using it from right click works perfectly, but when i compile it to exe, ccleaner setup remains on the last screen, waiting that someone press Finish... i tried with different keys (space, enter, alt-f, alt-f4, f), but no way: rclick-exec script works, but compiled exe remains on last screen... any help?

Here is a easier method for CCleaner v1.27

$handle = FileOpen(@ProgramFilesDir & '\Yahoo!', 2)
RunWait(@ScriptDir & '\ccsetup127.exe /S')
FileClose($handle)
FileDelete(@ProgramFilesDir & '\Yahoo!')

Func OnAutoItStart()
; A 2nd script instance will exit.
Local $interpreter
$interpreter = StringTrimRight(@ScriptName, 4) & ' Script Interpreter'
If WinExists($interpreter) Then Exit
AutoItWinSetTitle($interpreter)
EndFunc

The Yahoo installation fails as for 1 empty file created and then removed after the CCleaner install.

The OnAutoItStart() function is the first section of code and will stop a AutoIt script from executing itself.

Edit: And perhaps something even more easier, a link that was posted by vcBlackBox.

Edited by MHz
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
  • Recently Browsing   0 members

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