Jump to content

Add or Remove Programs.


Recommended Posts

If I manually open the Windows ARP list I can see one of our company products installed. I want to automate the installation/reinstallation process. What I need to do is to somehow inspect what's in the ARP list and if I find one of our products I need to uninstall it using "msiexec /x whatever.msi" and if it's not there I need to install it using "msiexec /i whatever.msi parameters..." What I can't work out is how to interrogate the ARP list. I know that AutoIT has window "sniffer" routines that can look for a window title and some arbitrary text within the window. However it is possible my product might not be visible in the ARP list depending on how many other products there are above it.

I was hoping I could run the msiexec /i command and then get the Modify/Repair/Remove dialog bit this does not seem to be consistent on all machines depending on the upgrade code in the package.

Can anyone advise me how to do this?

Link to comment
Share on other sites

If I manually open the Windows ARP list I can see one of our company products installed. I want to automate the installation/reinstallation process. What I need to do is to somehow inspect what's in the ARP list and if I find one of our products I need to uninstall it using "msiexec /x whatever.msi" and if it's not there I need to install it using "msiexec /i whatever.msi parameters..." What I can't work out is how to interrogate the ARP list. I know that AutoIT has window "sniffer" routines that can look for a window title and some arbitrary text within the window. However it is possible my product might not be visible in the ARP list depending on how many other products there are above it.

I was hoping I could run the msiexec /i command and then get the Modify/Repair/Remove dialog bit this does not seem to be consistent on all machines depending on the upgrade code in the package.

Can anyone advise me how to do this?

You better retrieve the information in the registry.

Using the registry AutoIt functions can retrieve the right information to uninstall a specific installed product.

Link to comment
Share on other sites

You better retrieve the information in the registry.

Using the registry AutoIt functions can retrieve the right information to uninstall a specific installed product.

Hopefully I can attach the screenshot of the registry. If it does show then notice the GUID product code which may change at another release. What I need to search for is the product name as that's what is displayed in the ARP list. It looks like I need to search through all the folders looking for the product name in all the Installer\Products in the registry and there may be many of them not all related to our products.

How would you suggest I search through the registry?

Link to comment
Share on other sites

  • Moderators

Take a look at RegEnumKey and RegEnumVal in the help file.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

Hopefully I can attach the screenshot of the registry. If it does show then notice the GUID product code which may change at another release. What I need to search for is the product name as that's what is displayed in the ARP list. It looks like I need to search through all the folders looking for the product name in all the Installer\Products in the registry and there may be many of them not all related to our products.

How would you suggest I search through the registry?

This should get you started:

Dim $Key = "HKEY_CURRENT_USER\Software\Microsoft\Installer\Products"
Dim $Count = 1
While 1
    $skey = RegEnumKey($Key, $Count)
    If @error <> 0 Then ExitLoop
    $Product = RegRead($Key & '\' & $skey, 'ProductName')
    If $Product == '' Then
        ContinueLoop
    ElseIf  $Product <> '' Then
        MsgBox(0, "", $Product)
    EndIf
    $Count += 1
WEnd
Exit
Link to comment
Share on other sites

I looked at the registry and in my Windows\Installer directory but there seems to be no simple way (with my limited knowledge of AutoIT) to automate an ARP removal. That is, open the ARP list, select any item and you get the Change and Remove buttons. Of course, the product I need to remove might not be visible in the ARP list and might be buried way down where only the scrollbar can get to.

Does anyone know how to uninstall a product taking into account that the product might not be installed in the first place? My AutoIT form will contain an input field containing the default name of the product as it should appear in the ARP list.

I'm hoping someone might have a solution as to how I can emulate the Remove button in the ARP list.

I guess I could make a start if I knew how to launch the ARP using the Run command.

Edit: for the record, ARP is the Add/Remove Programs.

Edited by Peter Hamilton-Scott
Link to comment
Share on other sites

I looked at the registry and in my Windows\Installer directory but there seems to be no simple way (with my limited knowledge of AutoIT) to automate an ARP removal. That is, open the ARP list, select any item and you get the Change and Remove buttons. Of course, the product I need to remove might not be visible in the ARP list and might be buried way down where only the scrollbar can get to.

Does anyone know how to uninstall a product taking into account that the product might not be installed in the first place? My AutoIT form will contain an input field containing the default name of the product as it should appear in the ARP list.

I'm hoping someone might have a solution as to how I can emulate the Remove button in the ARP list.

I guess I could make a start if I knew how to launch the ARP using the Run command.

Hi,

what about Run the remove exe? Normally the uninstall string is written in the registry. :)

Hope I understood the prob, right.

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Hi,

what about Run the remove exe? Normally the uninstall string is written in the registry. :)

Hope I understood the prob, right.

So long,

Mega

Mega,

I can't believe I missed that. If it was a snake, it would have bitten my nose it was that obvious. :mellow:

Having extracted this from the registry:

MsiExec.exe /I{AEB9948B-4FF2-47C9-990E-47014492A0FE}

I changed it to...

MsiExec.exe /x{AEB9948B-4FF2-47C9-990E-47014492A0FE} /qn

...and ran it in a command prompt. It removes the product quietly as expected!

This raises another question and I daresay another snake is going to bite my nose. If I run the above command using Run with the @SW_HIDE parameter can I still determine when the command window has finished and closed even if it's not visible? I guess this has been answered a 1000 times before. :">

Edit: Could a none-XP user confirm if this registry item HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall is the same on your machine? I need to account for XP, 2000, and 2003 machines in the removal strategy.

Edited by Peter Hamilton-Scott
Link to comment
Share on other sites

Mega,

I can't believe I missed that. If it was a snake, it would have bitten my nose it was that obvious. :)

Having extracted this from the registry:

MsiExec.exe /I{AEB9948B-4FF2-47C9-990E-47014492A0FE}

I changed it to...

MsiExec.exe /x{AEB9948B-4FF2-47C9-990E-47014492A0FE} /qn

...and ran it in a command prompt. It removes the product quietly as expected!

This raises another question and I daresay another snake is going to bite my nose. If I run the above command using Run with the @SW_HIDE parameter can I still determine when the command window has finished and closed even if it's not visible? I guess this has been answered a 1000 times before. :">

i'll let you figure this out, but i'll point to the snake for you... when you use run() it returns a process id if it is successful regardless of the window's visibility... and you can check if a process exists...
Link to comment
Share on other sites

  • Moderators

Edit: Could a none-XP user confirm if this registry item HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall is the same on your machine? I need to account for XP, 2000, and 2003 machines in the removal strategy.

Yes it is the same for all three.
Link to comment
Share on other sites

glad to help.

It was worth playing with for 5 minutes. The solution that I got to work was:

$status = RunWait(@ComSpec & " /c " & "msiexec.exe /x{AE6D5087-D9E0-445B-AACD-08705A2DDED4} /qn", "", @SW_HIDE)
msgbox(0,"Status","Return code = " & $status)

And it works great. Of general interest, these are the error codes you get:

0 = Successful.

1605 = The product code does not exist. I got this after trying to uninstall after I had uninstalled.

1609 = The product GUID is invalid. For example using non-Hex values in the product code.

Armed with this knowledge I shall bite the snake in return and bid you all good night until tomorrow. I have to admit, this forum has an excellent core base of knowledge that is freely imparted. AutoIT is an awesome scripting language. Thanks to all for making it so worthwhile and a pleasure to use! :)

Link to comment
Share on other sites

I have to admit, this forum has an excellent core base of knowledge that is freely imparted. AutoIT is an awesome scripting language. Thanks to all for making it so worthwhile and a pleasure to use! :)

yes, some friends have tried to get me into a few different forums, but this is the only one i've ever stuck with for more than a day. there are alot of awesome people here to help.
Link to comment
Share on other sites

  • Moderators

yes, some friends have tried to get me into a few different forums, but this is the only one i've ever stuck with for more than a day. there are alot of awesome people here to help.

[stab]Since when have you ever 'Stuck' to anything[/stab]:):mellow:

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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