Jump to content

Basic Auto-It introductory lessons


 Share

Recommended Posts

seems like it would be easier to just use the /S for silent install switch from commandline

You'll need to sign the agreement and wait for the special installer to have a /s silent install switch, then you'll that installer to be available wherever you run the script of course. Also what does it do if there are Browsers running at the time?

Test my code works on Windows XP, I'll see if I can test on Windows 7.

Link to comment
Share on other sites

You'll need to sign the agreement and wait for the special installer to have a /s silent install switch, then you'll that installer to be available wherever you run the script of course. Also what does it do if there are Browsers running at the time?

Test my code works on Windows XP, I'll see if I can test on Windows 7.

apparently reading the two line summary under google results has screwed me again ;) i'm not personally having the issue i just googled for "install_flash_player.exe command line silent" and the first result (from appdeploy.com) mentioned /S silent mode in the summary. looked pretty cut and dry
Link to comment
Share on other sites

I've just tested on Windows 7 64-bit system, and worked fine.

I did add the #RequireAdmin check at the top, as although this won't require admin rights, the Flash Installer it launches will, and I don't see an option for specifying that in Run(), unless someone can enlighten me?

I also added the Restart vars at the top, I've explicity set them to false for readability, but not specifying that they'll be false anyway, this is so it doesn't throw up an error if you're not running any of the three browsers.

Here's an AVI vid (had to zip it to post it on here), there's a pause and nothing happens for a bit, that's the UAC kicking in which you can see, but after that you can see where my mouse is and it doesn't move, yet the installer goes at a lightening pace and completes and closes.

I haven't tried it on Win7 with any of the browsers open yet.

#RequireAdmin
Opt("PixelCoordMode", 2)

$fRestartFirefox = False
$fRestartOpera = False
$fRestartSafari = False

$fPID = Run("install_flash_player.exe")
$fHND = WinWait("Install Adobe Flash Player", "This program will install")
ControlSend($fHND, "", "[CLASS:Button;INSTANCE:4]", "{SPACE}")
ControlSend($fHND, "", "[CLASS:Button;INSTANCE:3]", "{SPACE}")

While 1
    If PixelGetColor(423, 123, $fHND) = 5987163 Then ExitLoop
    If WinExists("Install Adobe Flash Player", "The installer will automatically continue when ") Then ; Installer is paused waiting to close
        If ProcessExists("firefox.exe") Then
            $fRestartFirefox = True
            ProcessClose("firefox.exe")
        EndIf
        If ProcessExists("opera.exe") Then
            $fRestartOpera = True
            ProcessClose("opera.exe")
        EndIf
        If ProcessExists("safari.exe") Then
            $fRestartSafari = True
            ProcessClose("safari.exe")
        EndIf
    EndIf
    Sleep(100)
WEnd
ControlSend($fHND, "", "[CLASS:Button;INSTANCE:3]", "{SPACE}")

; Restart any closed Browsers
If $fRestartFirefox Then
$FireFoxVer = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox\","CurrentVersion")
$FireFoxEXE = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox\" & $FireFoxVer & "\Main\","PathToEXE")
$ffPID = Run($FireFoxEXE)
$ffHND = WinWait("Restore Session - Mozilla Firefox", "")
ControlSend($ffHND, "", "", "R")
EndIf
If $fRestartOpera Then
$OperaEXE = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Opera Software\","Last CommandLine")
$oPID = Run($OperaEXE)
$oHND = WinWait("Welcome to Opera", "")
ControlSend($oHND, "", "", "{ENTER}")
EndIf
If $fRestartSafari Then
$SafariEXE = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Apple Computer, Inc.\Safari\","BrowserExe")
Run($SafariEXE)
EndIf

Exit

vid.zip

Edited by AJStevens
Link to comment
Share on other sites

There is definately something fishy with this.

After I run/ShellExecute install_flash_player.exe my scripts exits code 0 without doing anything else.

#RequireAdmin
$exe = Run("install_flash_player.exe")
$timer = TimerInit()
Sleep(15000)
WinWait("Install Adobe Flash Playe","")
$hInstall = WinWaitActive("Install Adobe Flash Playe","")
ConsoleWrite(TimerDiff($timer) & @LF)

That code starts the installer, then as soon as I hit the UAC button the script is finished before the app window even appears

It dosen sleep, and it dosent write to the console.

I'm having a bad day though so perhaps I've made a schoolboy error.

EDIT:

sorry forgot the require admin, and to mention its works as expected without the #RequireAdmin

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

There is definately something fishy with this.

After I run/ShellExecute install_flash_player.exe my scripts exits code 0 without doing anything else.

#RequireAdmin
$exe = Run("install_flash_player.exe")
$timer = TimerInit()
Sleep(15000)
WinWait("Install Adobe Flash Playe","")
$hInstall = WinWaitActive("Install Adobe Flash Playe","")
ConsoleWrite(TimerDiff($timer) & @LF)

That code starts the installer, then as soon as I hit the UAC button the script is finished before the app window even appears

It dosen sleep, and it dosent write to the console.

I'm having a bad day though so perhaps I've made a schoolboy error.

EDIT:

sorry forgot the require admin, and to mention its works as expected without the #RequireAdmin

hmm.. missing the "r" off Flash Player, but I doubt that's it. Does install_flash_player.exe actually start? You might want to put a full path to it, if you're running from SciTE, I compiled it into an exe for testing on Windows 7 and specified a UNC path to the install_flash_player.exe

It works as expected without the #RequireAdmin? That's strange.. I found the script just got stuck waiting and couldn't launch the install_flash_player.exe without it first having #RequireAdmin using Run, had to switch to ShellExecute to get the UAC prompt, however I then found the script stalled waiting, is that what's happening?

Hmm.. it does seem as though in that setup, it's not paying attention to the ControlSend commands... interesting...

Still.. I mean if you're going to make a script to install stuff, you'd want the #RequireAdmin flag surely?

Edited by AJStevens
Link to comment
Share on other sites

Yes the install starts, but the script has ended by then, its quite odd.

Ok if you're using #RequireAdmin it works fine.

If you're not using #RequireAdmin then if you're using Run, it'll stall at trying to launch the installer.

If you're not using #RequireAdmin then if you're using ShellExecute, then it'll start the installer, try to send commands, but they don't register, and carry on with the script and finishes.

Try a MsgBox instead of ConsoleWrite, maybe it can't write to the console, same as it can't send control commands to Adobe Flash.

This must be a Windows 7 security thing, surely?

Link to comment
Share on other sites

I've tired all that jazz.

#RequireAdmin

$exe = ShellExecute("install_flash_player.exe")
;UAC appears asking if I want to continue

;I choose continue

;Open File - Security warning.. do you want to run this file.. adobe etc...

;I choose Run

;At this point the script reports in the console window 
;that it has exited normally.

;Next the flash install app turns up
;closely followed by the magbox with the correct window handle.
;but no console output

$timer = TimerInit()
WinWait("Install Adobe Flash Player","")
$hInstall = WinWaitActive("Install Adobe Flash Player","")
ConsoleWrite(TimerDiff($timer) & @LF & $hInstall & @LF)
MsgBox(0,"Install",$hInstall)
I've no doubt its my dodge computer.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

;Open File - Security warning.. do you want to run this file.. adobe etc...

Might be this bit, I usually right-click my downloads, properties and click "unblock" so I don't get the Open File - Security warning.

I've no doubt its my dodge computer.

It could also be that... lol

Edited by AJStevens
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...