Jump to content

Cannot automate visual studio 2010 install via AutoIt


Recommended Posts

Hi Folks, new here and brand new to scripting in general. 

I have begun to make a script that will allow for an unattended installation of an addin my company is deploying. However, this executable has dependencies in its installer, and one is .NET. That part works fine. The Visual Studio part, however, when i insert a ControlClick command, it..... just doesnt do anything. I searched the forums and i didnt see anything about *installing* studio 2010 via AutoIt.

Thank you very much for anyone who can either point out an obvious blunder on my part or perhaps inform me as to why visual studio 2010 installer cant be controller by autoit.

Thanks!

 

#cs ----------------------------------------------------------------------------


 AutoIt Version: 3.3.8.1
 Author:         Josh Elliott


 Script Function:
Deploy NetSuite for Outlook Addin.


#ce ----------------------------------------------------------------------------


RunAs ( "myself", "domain", "password", 0, "\\\server\path\NetSuiteForOutlook.exe" )
WinWaitActive( "NetSuite for Outlook Installer")
ControlClick("NetSuite for Outlook Installer", "", 1000)
If RegRead ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Install", "1") Then 
   WinWaitActive("Microsoft Visual Studio 2010 Tools for Office Runtime (x64) Setup")
Else 
   WinWaitActive("Microsoft .NET Framework 4.0 - Client - Download")
   ControlClick("Microsoft .NET Framework 4.0 - Client - Download", "", 1012)
   WinWaitActive("Microsoft .NET Framework 4 Client Profile Setup")
   ControlClick("Microsoft .NET Framework 4 Client Profile Setup", "", 104)
   ControlClick("Microsoft .NET Framework 4 Client Profile Setup", "", 12324)
   ControlClick("Microsoft .NET Framework 4 Client Profile Setup", "", 12325)
EndIf
;If RegRead (
   WinWaitActive("Microsoft Visual Studio 2010 Tools for Office Runtime (x64) Setup")
   Send("{Enter}")
   ;ControlClick("Microsoft Visual Studio 2010 Tools for Office Runtime (x64) Setup", "", 29, 14)
   ;ControlClick("Microsoft Visual Studio 2010 Tools for Office Runtime (x64) Setup", "", 285)
   ;ControlClick("Microsoft Visual Studio 2010 Tools for Office Runtime (x64) Setup", "", 289)

 

Link to comment
Share on other sites

  • Moderators

Why not just use Microsoft's documentation and create a silent install, so you're not having to ControlClick through it? The guide is for 2012, but works on 2010 as well.

 

http://msdn.microsoft.com/en-us/library/ee225237.aspx

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Thanks for your response! 

Apparently I can only make 8 more posts until the 3rd of August lol.

I do apologize, but I dont know fully what you mean. Do you mean create a second process that will install VS 2010 first and then run my script afterwards? Or is there a way to add a microsoft script into my autoit one? If thats the case, ill be sold :) 

Link to comment
Share on other sites

  • Moderators

Basically, if you read through the post I linked to, you make your customizations and they get saved to an xml file. In your AutoIt script, you would then just call the execuatable. Something like this:

ShellExecute("\\server\share\vs_Product.exe", "/adminfile <path to xml> /quiet /norestart")

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

I just figured out where the problem stems from, but i still don't know how to fix it. I made it pas everything, but when it came to do the NetSuite installer, it wont work either. So, I copied the controlclick code into a new script with nothing else in it and when the appropriate window was up, i ran the script and it clicked "next" for me! But in my script, it wont... I have no idea how to figure out why. Any help is greatly appreciated!

 

#cs ----------------------------------------------------------------------------


 AutoIt Version: 3.3.8.1
 Author:         Josh Elliott


 Script Function:
Deploy NetSuite for Outlook Addin.


#ce ----------------------------------------------------------------------------


RunAs ( "me", "domain", "secret", 0, "\\serverpath\NetSuiteForOutlook.exe" )
If RegRead ( "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\DevDiv\trin\Servicing\10.0\trir\1033", "1") Then 
   WinWaitActive( "NetSuite for Outlook Installer")
Else 
ShellExecute("\\serverpath\vstor40_x64.exe", "/adminfile <\\serverpath\gpo\netsuite.xml> /quiet /norestart")
WinWaitActive( "NetSuite for Outlook Installer")
EndIf


ControlClick("NetSuite for Outlook Installer", "", 1000)


If RegRead ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Install", "1") Then 
   WinWaitActive("NetSuite for Outlook Setup")
Else 
   WinWaitActive("Microsoft .NET Framework 4.0 - Client - Download")
   ControlClick("Microsoft .NET Framework 4.0 - Client - Download", "", 1012)
   WinWaitActive("Microsoft .NET Framework 4 Client Profile Setup")
   ControlClick("Microsoft .NET Framework 4 Client Profile Setup", "", 104)
   ControlClick("Microsoft .NET Framework 4 Client Profile Setup", "", 12324)
   ControlClick("Microsoft .NET Framework 4 Client Profile Setup", "", 12325)
   WinWaitActive("NetSuite for Outlook Setup")
EndIf


ControlClick("NetSuite for Outlook Setup", "", 399)
Link to comment
Share on other sites

jelliott,

Your code is conditional based on use of If... so which ControlClick works and the state of .Net client installed is of concern? But rather then answering that question at present, I consider that your conditional logic may be the cause of your woes to first look at.

That registry location you posted is not what I have in registry and I have both v4 full and client of .Net installed.

Here is a test script I tested with.

; original attempt
If RegRead ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Install", "1") Then
    MsgBox(0, '1st', 'installed')
EndIf

; failure returns a string. success returns a double from this registry value. So I will cast the possible double to string to ensure a string comparison
If String(RegRead("HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client\1033", "Install")) = "1" Then
    MsgBox(0, '2nd', 'installed')
EndIf

I fail to see the 1st MsgBox yet I see the 2nd Msgbox. The 2nd attempt is with the information that I copied from my registry. The 1033 key is Locale ID for US language so it may be different depending on Locale ID set on another system.

This test shows that your original attempt with the registry path does the opposite behavior with RegRead then what my registry path does. I am not sure if that registry path that you are using is created during install and that it is removed at the end of the install. I do not use the software Network Suite For Outlook to know the behavior of the installation.

Link to comment
Share on other sites

When checking to determine whether or not a particular software application is installed, I think it's most reliable to check against Add/Remove Programs (WinXP) / Programs and Features (Vista and above):

  • HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionUninstall
  • HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftWindowsCurrentVersionUninstall - (For 32-bit software installations on a 64-bit OS)

These are what I always use.

Link to comment
Share on other sites

When checking to determine whether or not a particular software application is installed, I think it's most reliable to check against Add/Remove Programs (WinXP) / Programs and Features (Vista and above):

  • HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionUninstall
  • HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftWindowsCurrentVersionUninstall - (For 32-bit software installations on a 64-bit OS)

These are what I always use.

That didnt work for me at all :/

Link to comment
Share on other sites

jelliott,

That's the root of the registry keys that you'll need to begin searching for whether what you are looking for is installed. For instance, on my Win7 (64-bit) PC, here are the relevant registry values for the .NET Framework 4:

  • Microsoft .NET Framework 4 Extended = HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionUninstall{8E34682C-8118-31F1-BC4C-98CD9675E1C2}DisplayName (or DisplayVersion)
  • Microsoft .NET Framework 4 Client Profile = HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionUninstall{F5B09CFD-F0B2-36AF-8DF4-1DF6B63FC7B4}DisplayName (or DisplayVersion)

Does that make sense?

Link to comment
Share on other sites

Yes it does, and thank you. My problem might be with my regread function, since its not working at all. I tried yours and Mhz paths to .net and no luck. I tested it with a msgbox just to confirm it can read it and it cant. I wonder why?

If RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client\1033", "Install" = "1") Then 
MsgBox (4,"mybox","w00t")
Link to comment
Share on other sites

What OS and bitness are you testing this on? If WinXP or Win7 (32-bit), try this:

$Value = RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{8E34682C-8118-31F1-BC4C-98CD9675E1C2}", "DisplayName")
If @error = 0 Then
    MsgBox (0,"Installed?", $Value)
Else
    MsgBox(0, "Installed?", "Not installed")
EndIf

If you are running a 64-bit OS, try this:

$Value = RegRead("HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{8E34682C-8118-31F1-BC4C-98CD9675E1C2}", "DisplayName")
If @error = 0 Then
    MsgBox (0,"Installed?", $Value)
Else
    MsgBox(0, "Installed?", "Not installed")
EndIf
Link to comment
Share on other sites

 

Yes it does, and thank you. My problem might be with my regread function, since its not working at all. I tried yours and Mhz paths to .net and no luck. I tested it with a msgbox just to confirm it can read it and it cant. I wonder why?

If RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client\1033", "Install" = "1") Then 
MsgBox (4,"mybox","w00t")

I am not going to test that as I know that the syntax is incorrect. The "1" is not part of the function parameter but a comparison value for testing with the function return value. Perhaps my adding String() initially confused you to change it  and to make this error.

So if you have .Net client installed then run this one line code in a script.

If RegRead("HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client", "Install") = "1" Then MsgBox(4, "mybox", "w00t")

The value of "install" is in the "Client" key as well as the "1033" key so use the "Client" key to avoid the concern of needing the Locale ID. My error for not seeing this before.

As an alternative to registry, you can use AdlibEnableRegister() to call a function periodically to see if the .Net Client windows exist and if exist then handle them with your ControlClicks.

You asked about a file test. Do you know of a file that is v4 .Net Client only? I am not sure if this could be reliable enough. As with attempts with reading the registry, you still have .Net Client windows showing. Sure, you seem to be reading the registry incorrect, but still the source of the problem is handling the unexpected windows. You make the choice, people are here to help you with your choice.

Link to comment
Share on other sites

Wow, Ive learned alot in the past three days! (Still have a long ways to go though)

So I now have three scripts and they all work.... except for UAC!!!

I have read through all of the forum posts regarding UAC i could find, but none have worked for me. Permanently disabling UAC is not an option, any advice? My company is smaller and I am the only admin, so If I need to make any changes to our network to allow for AutoIT packages, ill do it! (besides permanently disable UAC ^_^ )

These are just a few of the things ive tried
#AutoIt3Wrapper_res_requestedExecutionLevel=HighestAvailable
RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", "EnableLUA", "REG_DWORD", "0")
#RequireAdmin
EnvSet("__COMPAT_LAYER", "RunAsInvoker")

And here are my scripts:

vs2010

RunAs ( "", ", "", 1, "\\Applications\vstor40_x64.exe" )
WinWaitActive ("Microsoft Visual Studio 2010 Tools for Office Runtime (x64) Setup")
ControlClick("Microsoft Visual Studio 2010 Tools for Office Runtime (x64) Setup", "", 289)
ControlClick("Microsoft Visual Studio 2010 Tools for Office Runtime (x64) Setup", "", 285)
ControlClick("Microsoft Visual Studio 2010 Tools for Office Runtime (x64) Setup", "", 289)
ControlClick("Microsoft Visual Studio 2010 Tools for Office Runtime (x64) Setup", "", 2)

net4

RunAs ( "", "", "", 1, "\Applications\dotNetFx40_Client_x86_x64.exe" )
WinWaitActive("Microsoft .NET Framework 4 Client Profile Setup")
ControlClick("Microsoft .NET Framework 4 Client Profile Setup", "", 104)
ControlClick("Microsoft .NET Framework 4 Client Profile Setup", "", 12324)
ControlClick("Microsoft .NET Framework 4 Client Profile Setup", "", 12325)

NetSuite

RunAs ("", "", "", 1, "\\Applications\NetSuiteForOutlook.exe")
If Not FileExists ( "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\vbc.exe") Then
   Run ("\\Applications\net4.exe")
   ;MsgBox(0, "Error", "Please contact your Local IT to install .NET 4")
ElseIf Not FileExists ( "C:\Program Files\Common Files\Microsoft Shared\VSTO\10.0\Microsoft Visual Studio 2010 Tools for Office Runtime (x64)\install.exe") Then
   Run ("\\Applications\vs2010.exe")
   ;MsgBox(0, "Error", "Please contact your Local IT to install Visual Studio 2010")
ElseIf FileExists ( "C:\Program Files (x86)\NetSuite for Outlook\SD2Loader.exe") Then
   MsgBox(0, "Error", "Please contact your Local IT to uninstall Previous Version of NetSuite")
Else
WinWaitActive("NetSuite for Outlook Installer")
ControlClick("NetSuite for Outlook Installer", "", 1000)
WinWaitActive("NetSuite for Outlook Setup")
ControlClick("NetSuite for Outlook Setup", "", 399)
ControlClick("NetSuite for Outlook Setup", "", 459)
ControlClick("NetSuite for Outlook Setup", "", 399)
ControlClick("NetSuite for Outlook Setup", "", 370)
EndIf

 

Once again, thank you guys for your help, its truly been invaluable.

Edit: I forgot to mention why UAC is a problem here. I am on my machine, logged in as domain admin making these changes and my machine has uac disabled, therefore, when i hit f5 to test the script, it all goes smoothly. If I log onto a different machine with domain admin, it doesnt work because uac is enabled, but does work when i disable it. and it certainly doesnt work as a standard user with uac on.

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