4

This is a really simple script that just uninstalls an application. Here is my code:

$app = Get-WmiObject -Class Win32_Product -Filter "Name = 'Alliance Suite G5'"

Write-Host $app

$app.Uninstall()

I put the Write-Host in just to make sure it was grabbing the correct application. Here is my output.

\COMPUTERNAME\root\cimv2:Win32_Product.IdentifyingNumber="{99B66721-7E75-487C-A0C8-A4F8C4325661}",Name="Alliance Suite G5",Version="2013.2.14226.1"

__GENUS : 2

__CLASS : __PARAMETERS

__SUPERCLASS :

__DYNASTY : __PARAMETERS

__RELPATH :

__PROPERTY_COUNT : 1

__DERIVATION : {}

__SERVER :

__NAMESPACE :

__PATH :

ReturnValue : 0

PSComputerName :

The return value is 0, but it never actually uninstalls the application. Any help would be appreciated! I run some automated tests at night and one of them installs the application so it would be nice if I could make a scheduled powershell script to uninstall it.

Event Viewer (NOTE: The product is "reconfigured several times before the second message):

Windows Installer reconfigured the product. Product Name: Microsoft Identity Extensions. Product Version: 2.0.1459.0. Product Language: 1033. Manufacturer: Microsoft Corporation. Reconfiguration success or error status: 0.

Beginning a Windows Installer transaction: {99B66721-7E75-487C-A0C8-A4F8C4325661}. Client Process Id: 8664.

Product: Alliance Suite G5 -- Removal completed successfully.

Windows Installer removed the product. Product Name: Alliance Suite G5. Product Version: 2013.2.14226.1. Product Language: 1033. Manufacturer: United Systems & Software. Removal success or error status: 0.

Result when running command:

C:\Windows\system32>msiexec.exe /X "C:\AllianceInstall\G5\Alliance.G5.exe" /QN /
L*V "C:\msilog.log

=== Verbose logging started: 8/18/2014 9:42:06 Build type: SHIP UNICODE 5.00.9200.00 Calling process: C:\Windows\system32\msiexec.exe === MSI (c) (5C:74)

[09:42:06:039]: Resetting cached policy values MSI (c) (5C:74)

[09:42:06:039]: Machine policy value 'Debug' is 0 MSI (c) (5C:74) [09:42:06:039]: * RunEngine: * Product: C:\AllianceInstall\G5\Alliance.G5.exe * Action: * CommandLine: ****** MSI (c) (5C:74)

[09:42:06:039]: Client-side and >UI is none or basic: Running entire

install on the server. MSI (c) (5C:74)

[09:42:06:039]: Grabbed execution mutex. MSI (c) (5C:74)

[09:42:06:061]: Cloaking enabled. MSI(c) (5C:74)

[09:42:06:061]: Attempting to enable all disabled privileges before calling Install on Server MSI (c) (5C:74)

[09:42:06:064]: Incrementing counter to disable shutdown. Counter

after increment: 0 MSI (s) (F8:48) [09:42:06:069]: Running installation inside multi-package transaction C:\AllianceInstall\G5\Alliance.G5.exe MSI (s) (F8:48) [09:42:06:069]: Grabbed execution mutex. MSI (s) (F8:64)

[09:42:06:071]: Resetting cached policy values MSI (s) (F8:64) [09:42:06:071]: Machine policy value 'Debug' is 0 MSI (s) (F8:64) [09:42:06:071]: * RunEngine:

       ******* Product: C:\AllianceInstall\G5\Alliance.G5.exe
       ******* Action: 
       ******* CommandLine: ********** MSI (s) (F8:64)

[09:42:06:072]: Note: 1: 2203 2: C:\AllianceInstall\G5\Alliance.G5.exe

3: -2147286960 MSI (s) (F8:64)

[09:42:06:073]: MainEngineThread is

returning 1620 MSI (s) (F8:48)

[09:42:06:074]: User policy value

'DisableRollback' is 0 MSI (s) (F8:48)

[09:42:06:074]: Machine policy

value 'DisableRollback' is 0 MSI (s) (F8:48)

[09:42:06:074]:

Incrementing counter to disable shutdown. Counter after increment: 0 MSI (s) (F8:48)

[09:42:06:074]: Note: 1: 1402 2:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\Rollback\Scripts 3: 2 MSI (s) (F8:48)

[09:42:06:074]: Note: 1: 1402 2:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\Rollback\Scripts 3: 2 MSI (s) (F8:48)

[09:42:06:075]: Decrementing counter to disable

shutdown. If counter >= 0, shutdown will be denied. Counter after decrement: -1 MSI (c) (5C:74)

[09:42:06:076]: Decrementing counter to

disable shutdown. If counter >= 0, shutdown will be denied. Counter after decrement: -1 MSI (c) (5C:74)

[09:42:06:076]: MainEngineThread

is returning 1620

=== Verbose logging stopped: 8/18/2014 9:42:06 ===

JLott
  • 1,818
  • 3
  • 35
  • 56
  • The program should have logged something either in EventLog or somewhere. Does the program uninstall manually? – Matt Aug 18 '14 at 13:58
  • Possibley an object is returned from `$app = Get-WmiObject -Class Win32_Product -Filter "Name = 'Alliance Suite G5'"` and you need to loop through it. I am checking now. – Matt Aug 18 '14 at 14:01
  • According to the event viewer, it was removed haha. Lies Windows... I am going to post the messages. – JLott Aug 18 '14 at 14:07
  • Most installers wont removed items that were change after an install to maintain customizations and supplementary information. What is persisting after install? – Matt Aug 18 '14 at 14:35
  • Everything. There is a folder that all the dlls are in, it is still listed in Programs and Features, and the shortcut is still there. – JLott Aug 18 '14 at 14:36
  • This might be an **Installshield suite** of MSI files wrapped in a single exe launcher. I have never used this project type. Essentially it is an EXE file that is used to treat several MSI files as a single product to install/uninstall. At least that is my understanding. You should be able to uninstall each individual MSI by finding its guid and uninstalling via msiexec.exe. Other than that you can try to run the "C:\AllianceInstall\G5\Alliance.G5.exe" manually and see what you get. – Stein Åsmul Aug 18 '14 at 14:56
  • When I run it manually I get a screen that allows me to repair, change, or uninstall the application. If I click Uninstall, everything works as it should. – JLott Aug 18 '14 at 15:05
  • Use Powershell to get a list of the installed products making up the suite: [**Use PowerShell to Quickly Find Installed Software**](http://blogs.technet.com/b/heyscriptingguy/archive/2011/11/13/use-powershell-to-quickly-find-installed-software.aspx). Then use the GUIDs you find and run the uninstall via msiexec.exe perhaps? – Stein Åsmul Aug 18 '14 at 15:10
  • This is just blowing my mind. \COMPUTERNAME\root\cimv2:Win32_Product.IdentifyingNumber="{99B66721-7E75-487C-A0C8-A4F8C4325661}",Name="Alliance Suite G5",Version="2013.2.14226.1" That does not show up when doing a "$app = Get-WmiObject -Class Win32_Product" but it does show up when I filter.... I also almost uninstalled a ton of stuff on my machine lol. – JLott Aug 18 '14 at 15:25
  • 1
    :-). This might be useful: [Passing Command-Line Parameters to a Package in an Advanced UI or Suite/Advanced UI Installation](http://helpnet.flexerasoftware.com/installshield19helplib/helplibrary/SteCmmndLne.htm). That Alliance.G5.exe likely supports a simple parameter such as /remove or something like that to uninstall the whole suite, but I am not sure. Heading out now, good luck. – Stein Åsmul Aug 18 '14 at 15:29
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/59519/discussion-between-glytzhkof-and-jlott). – Stein Åsmul Aug 18 '14 at 15:36
  • I have updated the [**uninstall msi answer**](http://stackoverflow.com/a/1055933/129130) I linked to with a notification about Installshield Suite projects. – Stein Åsmul Aug 19 '14 at 11:55

3 Answers3

2

It appears this is an Installshield suite project - essentially a collection of MSI files treated as a single product via some custom Installshield constructs. It appears to be a setup.exe type launcher that also is registered to handle ARP repair / modify.


In chat JLott confirmed that this command worked:

Alliance.G5.exe /remove /s

Full command used by JLott:

C:\Windows\system32>Start C:\AllianceInstall\G5\Alliance.G5.exe /remove /s

In addition to the above, you should be able to uninstall each individual MSI by finding its GUID and uninstalling via msiexec.exe.

This simple powershell command will provide a list of installed products with "identifying code". You can pass this code to Windows installer like this: msiexec.exe /x {GUID-HERE}

get-wmiobject -class Win32_Product 

enter image description here

Or you could select to view it in list form:

get-wmiobject Win32_Product | Format-Table IdentifyingNumber, Name, Version

enter image description here

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
1

You must verify that the product actually uninstalls correctly in the first place. Please try to read the following article and test the uninstall in different ways: Uninstalling MSI files

I would recommend trying to log the whole uninstall and see what the log says:

msiexec.exe /X "C:\Install.msi" /QN /L*V "C:\msilog.log"

or if you have the GUID (see linked article above for how to find it):

msiexec.exe /X {YOUR-GUID-HERE} /QN /L*V "C:\msilog.log"
Community
  • 1
  • 1
Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
  • Is this using command line? I can uninstall the product through the "Programs and Features" tool. – JLott Aug 18 '14 at 14:27
  • Yes, this is msiexec.exe - the Windows Installer command line. Do read the article that I linked for a better overview. The Powershell entry there was added by someone else, I have never tried it. The other options I added. – Stein Åsmul Aug 18 '14 at 14:27
  • Also if you can find the right UninstallString data, in the registry for your product under HKLM\software\microsoft\windows\currentversion\uninstall\{a_uniqueID}. Use Edit >Find to aid your search. The UninstallString contains the command executed from programs and features when you click uninstall. This is more useful for programs that are not MSI's – Matt Aug 18 '14 at 14:39
  • I am going to post the result from msiexec.exe command line. I had the same result and I am wondering if it is how the installer is set up... When you run the installer, there are several options on the screen. Maybe I have to have an argument when uninstalling it. I am really not sure. – JLott Aug 18 '14 at 14:45
  • Also look under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall for the "UninstallString" entry. This is the command that is actually run when you click remove in Add/remove programs. Most likely that just opens the standard dialog you get when you run the Alliance.G5.exe manually. – Stein Åsmul Aug 18 '14 at 15:35
1

Why is that msiexec command pointing to an executable? That's incorrect. You use the /X command passing the ProductCode. You must use that if you don't have the original MSI file.

This vbscript will list all the installed MSI products on the system, reporting their names and ProductCodes. Use it to find the ProductCode and use it in an msiexec command, if that's the direction you want to go. Save it as .vbs file and run it.

Option Explicit

Public installer, fullmsg, comp, prod, a, fso, pname, ploc, pid, psorce, pcache

Set fso = CreateObject("Scripting.FileSystemObject")
Set a = fso.CreateTextFile("prods.txt", True)

' Connect to Windows Installer object

Set installer = CreateObject("WindowsInstaller.Installer")

a.writeline ("Products")

on error resume next

For Each prod In installer.products

   pid = installer.productinfo (prod, "ProductID")

   pname = installer.productinfo (prod, "ProductName")

   psorce=installer.productinfo(prod, "InstallSource")

   ploc = installer.productinfo (prod, "InstallLocation")  

 pcache = installer.productinfo(prod, "LocalPackage") 

   a.writeline (prod & " " & pname & " installed at " & ploc & " from " & psorce & " cached at " & pcache)

Next
Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
PhilDW
  • 20,260
  • 1
  • 18
  • 28
  • When I ran that, I was able to find the msi @ C:\Windows\Installer\191986.msi Would that be the one that needs to be used with the /X command. – JLott Aug 18 '14 at 19:36
  • 1
    There are likely several MSI files that are uninstalled at once with the `Alliance.G5.exe /remove /s` command. The 191986.msi is likely one of them. That file name is random by the way, and will likely change if you reinstall the suite. – Stein Åsmul Aug 19 '14 at 02:43