Jump to content

Why is this working when I run it "as administrator" from the deskop but not when I deploy it and run it was local system?


Recommended Posts

I have an installer that I need to be able to put down on new machines as they are provisioned.  Unfortunately the only .exe installer that the vendor provides appears to require manually clicking through the installation.  So I'm trying to essentially build a macro that will launch the exe and then click through the install.  Below is my code (with sensitive data stripped out obviously).  When I compile this into an EXE and then right-click/run as administrator on a machine, it seems to work just fine.  However when I deploy it out to a machine via our software distribution system (LDMS) which runs it as local system, it doesn't always seem to grab the right window or click the right button to move it all the way through?

 

At first, the first winwait, winactivate, and controlclick wasn't working, and I would find that if I manually clicked the "Install" button, the rest of the script would work flawlessly.  However, when I changed the first bunch of code, now the second section of code doesn't seem to work (and again, I find the machine sitting waiting for me to click the "NO" button, and then everything proceeds once again.

What am I missing?  I've also attached screenshots of the window info for each step of the way if that helps.


 

#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=C:\Program Files (x86)\AutoIt3\Icons\au3script_v10.ico
#AutoIt3Wrapper_Res_Fileversion=4.0.0.14
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
#AutoIt3Wrapper_Res_LegalCopyright=
#AutoIt3Wrapper_Res_Language=1033
#AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

; Script Start - Add your code below here

#Include <MsgBoxConstants.au3>


If FileExists("C:\Program Files (x86)\Silver Bullet Technology") Then
    MsgBox($MB_SYSTEMMODAL, "Error", "''C:\Program Files (x86)\Silver Bullet Technology\'' already exists!  Please completely uninstall all components before running this installation.  Nothing has been installed.")
    Exit(1)
Else


$iZone = 0 ; My Computer
;$iZone = 1 ; Local Intranet Zone
;$iZone = 2 ; Trusted sites Zone
;$iZone = 3 ; Internet Zone
;$izone = 4 ; Restricted Sites Zone

;In order to allow us to use the IE Zone settings in the registry under HKCU we must first disable "FEATURE_LOCALMACHINE_LOCKDOWN" which appears to be enabled by default
;We will later (at the very end of this script) turn this back on for security reasons
RegWrite("HKCU\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_LOCALMACHINE_LOCKDOWN", "iexplore.exe", "REG_DWORD", 0)

;Here we must "allow active content to run files on my computer" in order for the alttiff active-x to install in IE during the installation
RegWrite("HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\" & $iZone, "1208", "REG_DWORD", 0)

Run("Fiserv_RangerForSmartSourcePVA_v4.4.1.0-2.0.37.0.exe")



WinWait("Fiserv Installation", "")
;WinWait("[CLASS:WindowsForms10.Window.8.app.0.141b42a_r6_ad1]", "")
;WinActivate("Fiserv Installation")
WinActivate("Fiserv Installation", "")
;ControlClick("[CLASS:WindowsForms10.Window.8.app.0.141b42a_r6_ad1]", "", "[CLASS:WindowsForms10.BUTTON.app.0.141b42a_r6_ad1; TEXT:Install; INSTANCE:1]")
;ControlClick("Fiserv Installation", "", "[CLASS:WindowsForms10.BUTTON.app.0.141b42a_r6_ad1; TEXT:Install; INSTANCE:1]")
Send("{Enter}")

WinWait("Fiserv Installation Complete: Please Restart Computer", "Changes have been made which require a restart of your workstation.")
;WinWait("[CLASS:WindowsForms10.Window.8.app.0.141b42a_r6_ad1]", "Changes have been made which require a restart of your workstation.")
WinActivate("Fiserv Installation Complete: Please Restart Computer", "Changes have been made which require a restart of your workstation.")
;WinActivate("[CLASS:WindowsForms10.Window.8.app.0.141b42a_r6_ad1]", "Changes have been made which require a restart of your workstation.")
ControlClick("Fiserv Installation Complete: Please Restart Computer", "", "[CLASS:WindowsForms10.BUTTON.app.0.141b42a_r6_ad1; TEXT:No; INSTANCE:1]")

WinWait("Fiserv_RangerForSmartSourcePVA_v4.4.1.0-2.0.37.0", "Changes have been made to your system to optimize functionality for SCO WebCapture.")
;WinWait("[CLASS:#32770]", "Changes have been made to your system to optimize functionality for SCO WebCapture.")
WinActivate("Fiserv_RangerForSmartSourcePVA_v4.4.1.0-2.0.37.0", "Changes have been made to your system to optimize functionality for SCO WebCapture.")
;WinActivate("[CLASS:#32770]", "Changes have been made to your system to optimize functionality for SCO WebCapture.")
ControlClick("Fiserv_RangerForSmartSourcePVA_v4.4.1.0-2.0.37.0", "", "[CLASS:Button; TEXT:OK; INSTANCE:1]")
;ControlClick("[CLASS:#32770]", "", "[CLASS:Button; TEXT:OK; INSTANCE:1]")

WinWait("Fiserv Installation", "Installation Complete")
;WinWait("[CLASS:WindowsForms10.Window.8.app.0.141b42a_r6_ad1]", "Installation Complete")
WinActivate("Fiserv Installation", "Installation Complete")
;WinActivate("[CLASS:WindowsForms10.Window.8.app.0.141b42a_r6_ad1]", "Installation Complete")
ControlClick("Fiserv Installation", "", "[CLASS:WindowsForms10.BUTTON.app.0.141b42a_r6_ad1; TEXT:Complete; INSTANCE:1]")
;ControlClick("[CLASS:WindowsForms10.Window.8.app.0.141b42a_r6_ad1]", "", "[CLASS:WindowsForms10.BUTTON.app.0.141b42a_r6_ad1; TEXT:Complete; INSTANCE:1]")

;Here we are simply re-enabling a setting we previously disabled in the beginning.
RegWrite("HKCU\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_LOCALMACHINE_LOCKDOWN", "iexplore.exe", "REG_DWORD", 1)

EndIf

 

screen info 1.jpg

screen info 2.jpg

screen info 3.jpg

screen info 4.jpg

Edited by HighSpeed556
left out some code at the top
Link to comment
Share on other sites

I do not think that standard AutoIt can be used on non Win32 controls. Best if you read FAQ 31, and in particular, IUIAutomation, or just stick to sending keys may be the best bet. 

WindowsForms10.Window.8.app.0.141b42a_r6_ad1 

is a Windows Forms app. So your code was working with this as admin?

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Link to comment
Share on other sites

19 hours ago, Earthshine said:

I do not think that standard AutoIt can be used on non Win32 controls. Best if you read FAQ 31, and in particular, IUIAutomation, or just stick to sending keys may be the best bet. 


WindowsForms10.Window.8.app.0.141b42a_r6_ad1 

is a Windows Forms app. So your code was working with this as admin?

This is not true.

I do believe the characters change on every relaunch though, so you need to use a regular expression, or instance based identification of the controls.

I suggest logging all actions and their outputs to a file so you know exactly what step is failing.

If nothing is executing, then I'd need more info on how you are initiating the script.  good things to note.   can your new user initiate elevated permission processes?   is UAC turned on?  what user session are you running on?   are you present to click UAC elevation message?

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

2 hours ago, Juvigy said:

Did you try to remove #requireadmin?

I have not tried that.  Last night I reverted to just changing all of the controlclicks to send functions with keystrokes.  This seemed to work.  This leads me to believe that everything else is working except the control clicks in the above code.  No?

Link to comment
Share on other sites

53 minutes ago, jdelaney said:

This is not true.

I do believe the characters change on every relaunch though, so you need to use a regular expression, or instance based identification of the controls.

I suggest logging all actions and their outputs to a file so you know exactly what step is failing.

If nothing is executing, then I'd need more info on how you are initiating the script.  good things to note.   can your new user initiate elevated permission processes?   is UAC turned on?  what user session are you running on?   are you present to click UAC elevation message?

How can I execute this on a machine and turn on logging to an output file like you speak of?  This would be handy if I could at least narrow down which section of the code it's hanging up on.

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