Jump to content

Need some help with autoit script.


tym

Recommended Posts

Forgive me I posted this in another part of the forum and goofed up. Forgot about this section. I need help with a autoit script. Its the last trick I need to be able to make anything install silent. Let me tell ya this One was HARD. Took me a couple of months just to figure it out. I am still really new to autoit. I know the "recording" part of it.

I am working on Norton ghost 2003. I have it install silently. No problem. I took the files needed and made a sfx file. The files needed included the silent switch, because with norton ghost, You can simply edit the setup.ini file in the install folder with the switch needed. Took me forever to figure out how to add that switch.

So I try it... the install it fails. So I change the switch to /passive to see what is going on. Ghost takes about a min to install. While it installs, other addons will start there install which makes nortons fail. While trying the addon by itself, Windows will not wait for the program to finish. So my next step is autoit. I warn you Im a real noobie with this program. I figure a couple of sucessful script install jobs and should give me a good head start. This script was made using the setup.exe and letting autoit make the script for me. Now I kinda understand some of it. Just not sure what needs to be changed to fix the install problem. Here it is. I guessed and use the winwaits option.

#region - setup install script - (Automated with WinWait functions)

Opt('TrayIconDebug', 1)

Opt('WinDetectHiddenText', 1)

Opt('WinTitleMatchMode', 4)

; Installer.

$executable = 'setup.exe'

; Show progess.

$splash = 0

; Default catagory folder in startmenu.

$group = ''

; New catagory to move the default folder into.

$catagory = ''

; Installation folder in Program Files.

$directory = ''

; Run the installer.

$pid = _Install()

If WinWait('', '', 60) Then

ControlClick('', '', '')

WinWait('', '')

ControlClick('', '', '')

WinWait('', '')

ControlClick('', '', '')

WinWait('', '')

ControlClick('', '', '')

WinWait('', '')

ControlClick('', '', '')

Else

_Abort()

EndIf

ProcessWaitClose($pid)

; Remove shortcuts.

If _MainShortcut('?.lnk') Then

; Relative to shortcut directories

; Remove Startmenu shortcuts

FileDelete('?.lnk')

FileDelete('?.lnk')

FileDelete('?.lnk')

FileDelete('?.lnk')

FileDelete('?.lnk')

; Remove other shortcuts

_Desktop('?.lnk')

_QuickLaunch('?.lnk')

EndIf

#endregion

Exit

Link to comment
Share on other sites


Hi tym,

The code displayed looks like template code generated from CMenu or SendToA3x. There is a help file included with these programs with a installation script example provided. You are going to need to use the "AutoIt Info Tool" supplied with AutoIt3 installation to get window titles, window text, control identification classes and what ever else is needed. You can also use AutoItMacrogenerator which is perhaps already supplied else you can get with an installation of Scite4AutoIt3 which contains it and can be used to generate an automated installation script with the values mentioned above filled in.

This is a script I have in use from a template created by SendToA3X. The principle is the same as adding in needed info though I placed the functions within a separate include script.


#region - VobSub install script - (Automated with WinWait functions)
#include <Common_Functions.au3>
Opt('TrayIconDebug', 1)
Break(False)

; Installer.
$executable = 'VobSub 2.23.exe'
; Default group folder in startmenu.
$group = 'VobSub'
; Installation folder in Program Files.
$directory = ''

; Run the installer.
$pid = _Automated()
$title = 'VobSub 2.23 Setup'
If WinWait('Installer Language', 'Please select a language', 60) Then
ControlClick('Installer Language', 'Please select a language', 'OK')
WinWait($title, 'Welcome to the VobSub Setup')
ControlClick($title, 'Welcome to the VobSub Setup', '&Next >')
WinWait($title, 'Choose Components')
ControlClick($title, 'Choose Components', '&Next >')
WinWait($title, 'Select the folder to install VobSub')
ControlClick($title, 'Select the folder to install VobSub', '&Install')
WinWait($title, 'Installation Complete')
ControlClick($title, 'Installation Complete', '&Close')
Else
_Abort()
EndIf
ProcessWaitClose($pid)

; Remove shortcuts.
If _Programs('VobSub Configure.lnk') Then
If FileMove($group & '\DirectVobSub Configure.lnk', 'Audio-Video\', 9) _
And FileMove($group & '\VobSub Configure.lnk', 'Audio-Video\', 9) Then
DirRemove($group, 1)
EndIf
EndIf

Exit
#endregion

Ask if you need more help.

:)

Link to comment
Share on other sites

MHz, I can not tell you how grateful I am for your help. I have had such a Horrid time finding Someone to help me with this. Its like its a big secret. I even posted in a forum that deals with kinda stuff all the time and a week later still no responce to my plea for help.

I am sure I will ask you TONS of questions. I thank you so very much for your help. So I am guessing the Autoitmicrogenerator is the program I need to start out with learning??

That helps lots. I was not sure even how to begin the learning process. I will start with the generator and learn that part of autoit. Feel free to correct me if I am wrong. I will learn this. Its gonna take time and work but something I have always wanted to learn, but like most was not even sure how to begin.

Have a nice day and once again I thank you so very very much.

Edited by tym
Link to comment
Share on other sites

Update.

I tried the microgenerator program, using nortons ghost setup.exe. I let it open and run and really ended up with nothing in the box but a single line. I have the program set up to install "passive" So I can see the progress bar. Will look around and see if I did something wrong with the generator.

I also tried autoit screen recorder, Now that seemed to give me a bit more to work with. Here is the script I ended up with that. I put the Exit in myself.

Opt("WinWaitDelay",100)

Opt("WinTitleMatchMode",4)

Opt("WinDetectHiddenText",1)

Opt("MouseCoordMode",0)

Run('C:\Documents and Settings\Administrator\Desktop\ghost 2003\setup.exe')

WinWait("Information","To help ensure compa")

If Not WinActive("Information","To help ensure compa") Then WinActivate("Information","To help ensure compa")

WinWaitActive("Information","To help ensure compa")

Send("{ENTER}")

Exit

Now it seems to me after the send command is sent I need to put in a line for a "winwaitdelay" to allow the program to install. I will stop here until

You get a bit of time to help. I may be going down the wrong path and Need to work more with the autoitmicrogenerator to compile a more workable script. Will wait on you.

I am also starting out with the tutorials. Will hopefully take a new step every day. Today I did the "hello world" script. I messed around for a min and kinda made a perverted one for the girlfriend. Had her click on it and the pop up box displayed a funny adult type message. We both got a tickle, and she was rather impressed I did that.

Seen a post that someone suggested learning the manual stuff to better understand the automated stuff and I kinda agree. Its starting to make sense.

Link to comment
Share on other sites

So I try it... the install it fails. So I change the switch to /passive to see what is going on. Ghost takes about a min to install. While it installs, other addons will start there install which makes nortons fail. While trying the addon by itself, Windows will not wait for the program to finish.

Back to 1st post as possible easy fix. If this is using CMD then you may try using "Start /Wait" to help with wait though a spawned process from msiexec maybe causing it to return early.

I am sure I will ask you TONS of questions. I thank you so very much for your help. So I am guessing the Autoitmicrogenerator is the program I need to start out with learning??

AutoItMacrogenerator is the easy option to create an automated installation script. You just run the program located in the Scite4AutoIt3 install at "C:\Program Files\AutoIt3\SciTE\AutoItMacroGenerator". I prefer to run it standalone rather then thrtough the editor so I can see lines added instantly. Click the red button to start recording, click the title of each window shown during installation and then click the controls (buttons, etc) needed. You should then get a quick and basic script for installation after completing the whole process of recording.

I tried the microgenerator program, using nortons ghost setup.exe. I let it open and run and really ended up with nothing in the box but a single line. I have the program set up to install "passive" So I can see the progress bar. Will look around and see if I did something wrong with the generator.

Unless the installer is Java or HTML based then I would expect the window and controls to be seen and recorded. Ensure that the recorder is in fact running.

I also tried autoit screen recorder, Now that seemed to give me a bit more to work with. Here is the script I ended up with that. I put the Exit in myself.

Opt("WinWaitDelay",100)

Opt("WinTitleMatchMode",4)

Opt("WinDetectHiddenText",1)

Opt("MouseCoordMode",0)

Run('C:\Documents and Settings\Administrator\Desktop\ghost 2003\setup.exe')

WinWait("Information","To help ensure compa")

If Not WinActive("Information","To help ensure compa") Then WinActivate("Information","To help ensure compa")

WinWaitActive("Information","To help ensure compa")

Send("{ENTER}")

Exit

The screen recorder can be used though it is not what I would refer as using functions suitable for automated installations. The screen recorder is more suitable for general desktop automation. The above script seems incomplete.

Now it seems to me after the send command is sent I need to put in a line for a "winwaitdelay" to allow the program to install. I will stop here until

You get a bit of time to help. I may be going down the wrong path and Need to work more with the autoitmicrogenerator to compile a more workable script. Will wait on you.

"winwaitdelay" is an option to wait time before interaction from the next line of code. It is not a concern to use normally.

I am also starting out with the tutorials. Will hopefully take a new step every day. Today I did the "hello world" script. I messed around for a min and kinda made a perverted one for the girlfriend. Had her click on it and the pop up box displayed a funny adult type message. We both got a tickle, and she was rather impressed I did that.

lol, I accept humor. ;)

Seen a post that someone suggested learning the manual stuff to better understand the automated stuff and I kinda agree. Its starting to make sense.

Yes, I prefer manual by using AutoIt Info Tool to gather information from the windows though I may sometimes use AutoItMacrogenerator as a lazy method. Doing it manually will help you learn. Using AutoItMacrogenerator is an easy option to begin with is why I mentioned it.

So if you can get a good start with the script then I can try to help you when you have problems. If Ghost installs fine using switches then you can try using ProcessWait() and ProcessWaitClose() on the spawned process to ensure wait time until end of installation so automation can be minimized.

:)

Link to comment
Share on other sites

I truly have a STRONG desire to learn this. While I so appreciate the simple fix. That is really not gonna teach me anything. You have taken the time to help me, I am gonna take advantage of the situation and take the opportunity to learn this. Its back to your suggestion of autoitmanager,

I will continue to use the same program just to keep it more simple. I realize most think Its nuts, Just take the simple fix and be done with it. I prefer to think long term. Learn while I have the chance and someone is willing to help me with it. That way it the future, I can tackle this on my own.

Shortcuts can be nice, but long term can bite ya in the bottom. So I am off to take another step in the tutorial, tackle autoitmanger, and will repost my new script. Have a nice day.

Link to comment
Share on other sites

Ok I figured out what I did wrong with the autoitmicrot tool. I had the switch still set to /passive. Once I got that removed that tool is really handy and pretty cool. Its like the screen recorder only it does it in text. Your are right. That is much easier to use. So here is my micro tool script. Did the lesson 2 thing today. The one with the notepad example. Pretty cool. I found that more useful for my needs. The popup was cute, but not something that I really wanna use. But was handy to learn about the flags and title and message thing.

If anyone else is kinda new and reading this thread. Really Go with the tutorials, Do one a day or as time allows. It really does help make sense of the stuff you see.

;--- AutoIt Macro Generator V 0.21 beta ---

Opt("WinTitleMatchMode", 4)

Run("C:\Documents and Settings\Administrator\Desktop\ghost 2003\setup.exe")

WinWait("Program Manager","FolderView")

$CLVItem = ControlListView("Program Manager","FolderView","SysListView321","FindItem","My Computer")

ControlListView("Program Manager","FolderView","SysListView321","SelectClear")

ControlListView("Program Manager","FolderView","SysListView321","Select",$CLVItem)

WinWait("Information","To help ensure compatibility w")

ControlClick("Information","To help ensure compatibility w","Button1")

WinWait("Norton Ghost 2003 - InstallShield Wizard","&Next >")

ControlClick("Norton Ghost 2003 - InstallShield Wizard","&Next >","Button1")

WinWait("Norton Ghost 2003 - InstallShield Wizard","I &accept the terms in the lic")

ControlClick("Norton Ghost 2003 - InstallShield Wizard","I &accept the terms in the lic","Button3")

ControlClick("Norton Ghost 2003 - InstallShield Wizard","I &accept the terms in the lic","Button5")

WinWait("Norton Ghost 2003 - InstallShield Wizard","&Organization:")

ControlClick("Norton Ghost 2003 - InstallShield Wizard","&Organization:","Button2")

WinWait("Norton Ghost 2003 - InstallShield Wizard","or click Change to install to ")

ControlClick("Norton Ghost 2003 - InstallShield Wizard","or click Change to install to ","Button1")

WinWait(" Norton Ghost 2003 - InstallShield Wizard","The wizard is ready to begin i")

ControlClick(" Norton Ghost 2003 - InstallShield Wizard","The wizard is ready to begin i","Button1")

WinWait("Please Register Norton Ghost 2003","As a world leader in Internet ")

ControlClick("Please Register Norton Ghost 2003","As a world leader in Internet ","Button5")

WinWait("Please Register Norton Ghost 2003","Are you sure you want to skip ")

ControlClick("Please Register Norton Ghost 2003","Are you sure you want to skip ","Button1")

WinWait("Norton Ghost 2003 - InstallShield Wizard","Binary11")

ControlClick("Norton Ghost 2003 - InstallShield Wizard","Binary11","Button1")

;--- End ---

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...