Jump to content

Have a very strange issue with script not running properly unless another script is running in the background.


Recommended Posts

Hello all,

I am new to software development and very new to AutoIT. I am trying to write a script that automates 16 software installations. I am in IT and this would make setting up new PCs very handy. I am running into an issue though. Whenever I have the "Open File - Security Warning" Window pop up, I have mapped the mouse to click the Run button no matter where the window is at on the desktop, it will always click the run button. However, If I run the script, it doesn't do anything. If I run the script immediately after, then it clicks like the code is running properly. I noticed when it does this there is the old script (au3 file) running in the system tray. If I close that and try again it does the exact same thing until I run it immediately after the first script run fails. I am really confused as to why it may be doing this, and I am concerned I am just coding things incorrectly. Any help would be appreciated. I am currently just creating functions for one software installation at a time, so I will post the function that I am currently struggling with. Thank you.

Func InstallSigWeb()
    Local $sRunDir = '\\uucu-mviserver\Tools\Drivers\SigWeb 1.7.0.0\sigweb_silent__tpz\'
    Local $sInstallFile = 'SigWeb1.7.0.0.msi'
    ShellExecute('"' & $sRunDir & $sInstallFile & '"', "")
    WinWaitActive("Open File - Security Warning")
    ; Maps the coords of the window
    ; Then moves the mouse to the button relative to the window corner
    Local $aCoord = WinGetPos("Open File - Security Warning")
    Local $iX = $aCoord[0] + 300
    Local $iY = $aCoord[1] + 200
    MouseClick("left", $iX, $iY)
    WinWaitActive("SigWeb Setup", "&Next >")
    Sleep(1000)
    Send("!n")
    WinWaitActive("SigWeb Setup", "License Agreement and Limited Warranty")
    ControlClick("SigWeb Setup", "", "1542")
    ControlClick("SigWeb Setup", "", "744")
    WinWaitActive("SigWeb Setup", "Choose the settings for your tablet.") ; CODE STOPS HERE FOR SOME REASON
    Send("{TAB 2}")
    Send("{RIGHT}")
    Send("{TAB 2}")
    Send("{RIGHT 4}")
    Send("{TAB}")
    Send("{RIGHT}")
    Send("!n")
    WinWaitActive("SigWeb Setup", "<&Back")
    Send("!n")
    WinWaitActive("SigWeb Setup", "Br&owse...")
    Send("!n")
    WinWaitActive("SigWeb Setup", "Topaz Systems, Inc.")
    Send("!i")
    WinWaitActive("SigWeb Setup", "&Finish")
    Send("!f")
EndFunc   ;==>InstallSigWeb

 

Link to comment
Share on other sites

A few things, always for automating an install have #RequireAdmin in the script, that should elevate everything and hopefully prevent any security popups after you kick it off.

 

Second 99% of everything can be silently installed without automating the GUI, in 15 years of doing this I have had only 1 or 2 things that did not have some method to silent install, even if it was a method I had to create myself.

 

Third for automating GUI's if you have to go that route I always place a WinActivate() before each step to ensure the windows is up and active.

And the last time I had a GUI automation fail like this it was because my text was not specific enough to wait for the correct window, and it was matching the previous window thus proceeding ahead in the script.

 

So, based on the above I think you should be able to install that file with MSIEXEC with the /qn flags to silently install, if you need to tweak specific parameters, you can probably edit the MSI file or create a MST file.

Link to comment
Share on other sites

So, I do have the #RequireAdmin directive at the top of my script just so you know. I didn't copy that code. I was just copying and pasting the function I designed that I was struggling with. Sorry for the communication issue on that.

Even though I have that directive it still pulls up this window.

image.png.d3aa0e7f235fb63c2e96772c6e333062.png

My Automation breaks at this point and won't click the Run button. Send("!r") also doesn't work. If I run the script again. Then the automation works and my MouseClick() works. I notice when this happens, in the system tray there is a copy of the script still running. If I close that script, and try again. My issue appears again. I am NOT sure why this is happening and I don't know how to fix it. It is a really strange issue.

 

Func InstallAdobeReader() ; FIX ME: This function is not finished
    local $sRunDir = '\\uucu-san\y\Default New PC Setup\'
    ; Install File Name
    local $sInstallFile = 'readerdc64_en_xa_crd_install.exe'
    ShellExecute('"' & $sRunDir & $sInstallFile & '"', "")
    WinWait("Open File - Security Warning")
    WinActivate("Open File - Security Warning")
    ; Maps the coords of the window
    ; Then moves the mouse to the button relative to the window corner
    Local $aCoord[4] = WinGetPos("Open File - Security Warning")
    Local $iX = $aCoord[0] + 300
    Local $iY = $aCoord[1] + 200
    MouseClick("left", $iX, $iY)
    WinWaitActive("Adobe Acrobat Reader DC Installer")
EndFunc   ;==>InstallAdobeReader

This function is doing the same thing. I wait with WinWait() and then I use WinActivate() and it still won't work until I run the script a second time. I think it has something to do with UAC, but I'm not sure.

Link to comment
Share on other sites

That almost definitely sounds like your script is getting ahead of itself and its catching it the 2nd time thru. 

You should be able to use control functions and not rely on coordinates to click, or at minimum purely keyboard commands.

 

Using coordinates can lead to a point of failure when people have different scaling options set on the computer.

 

Check your WinWait() and ensure that the text used can not match the pre-existing window.

Link to comment
Share on other sites

Func InstallAdobeReader() ; FIX ME: This function is not finished
    local $sRunDir = '\\uucu-san\y\Default New PC Setup\'
    ; Install File Name
    local $sInstallFile = 'readerdc64_en_xa_crd_install.exe'
    ShellExecute('"' & $sRunDir & $sInstallFile & '"', "")
    WinWait("Open File - Security Warning", "Publisher:")
    WinActivate("Open File - Security Warning", "Publisher:")
    ControlClick("Open File - Security Warning", "&Run", "4426")

EndFunc

So this is my code now and it refuses to ControlClick() I have even tried Send("!r") because the window shows that you can but it won't automate this window. I believe that this specific window resists automation so that's why I did the coordinate click, that worked. I wrote a function to get the size of the window no matter where it is at on the screen and navigate to it.

Link to comment
Share on other sites

BTW Adobe Reader always has a silent install.  I just built one the other day for the newest version.

If this is a learning journey I support you for trying to find solutions and learn, if its strictly for getting a task done and you want it as professional and seamless as possible, you will want to set this up as a zero touch silent install. 

Link to comment
Share on other sites

Would I have to call the cmd prompt in order to run a silent install?

I am trying to do this for the Help Desk so that they just run this script and then it installs 16 different software. Some of these need you to click on configurations to set them up properly. Adobe is not one of them. So I could do a silent install on a few of these applications.

How would my script know to move onto the next software though if there are no dialogs?

Link to comment
Share on other sites

Because when you run a command like MSIEXEC the next part of the script wont run until it returns.

I just use .bat files for this stuff and only AutoIT for really advanced things, so from Autoit you could use ShellExecuteWait() or RunWait() so it waits for a return before proceeding.

Even if something requires configuration, chances are those configs are saved to a file that you can copy post install, or parameters you can set during the install.

 

Like I said 99% of the time a silent install is possible.

 

For enterprise I use MSI files as much as possible, so I always extract the Adobe .exe's to a MSI file and then you can use the Adobe Customization Wizard to create a MST that has any features set you need and create a MST file.

 

Here is the .bat I use for Adobe Reader, it allows techs to install it in one click easy and also how I call the install from SCCM.

Then I can just also call the .BAT from Autoit or another .BAT file if some kind of sequence of events is needed.

Also leaves me a nice paper trail to verify things down the road.

 

pushd %~dp0
MKDIR C:\Automate\Logs
Set Logfile="C:\Automate\Logs\AdobeReaderDC_Install.log
Echo %time% %date% Batch Install Started by %username% >> %logfile%
Echo %time% %date% Starting Install of Adobe Reader DC v21.7.20091.59174 >> %logfile%
msiexec.exe /qn /i "AcroRead.msi" TRANSFORMS="Enterprise_Modifications.mst" /L*V C:\Automate\Logs\AdobeReaderDC_Install_MSI.log
Echo %time% %date% Starting Install of Adobe Reader DC v21.7.20091.59174 Update Patch >> %logfile%
msiexec.exe /p AcroRdrDCUpd2100720091.msp /qn /L*V C:\Automate\Logs\AdobeReaderDCPatch_Install_MSI.log
Echo %time% %date% Completed Install of Adobe Reader DC v21.7.20091.59174 >> %logfile%
popd

 

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