Jump to content

Uninstall a product through wmi with new installshield


Recommended Posts

I tried this on a laptop at work

$oWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & @ComputerName & "\root\cimv2")
$aProducts = $oWMI.ExecQuery("Select * from Win32_Product Where Name LIKE '%CyberLink Power2Go 8%'")

For $app in $aProducts
    $app.Uninstall()
Next

And it completely ignored it, but when i did this

$oWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & @ComputerName & "\root\cimv2")
$aProducts = $oWMI.ExecQuery("Select * from Win32_Product Where Name LIKE '%Power2Go%'")

For $app in $aProducts
    $app.Uninstall()
Next

It uninstalled it but damaged the programs and features entry so it threw an error if you used it after

does a space not count as a letter?

and why did the second one damage the uninstaller?

Link to comment
Share on other sites

The space should not be an issue its just using that to search the name and if it matches a name it is using the full result of the search to do the uninstall.

Maybe just maybe there was more to the name than you thought that caused the first search to fail where the 2nd one did not.

As for the failed uninstall, I imagine thats just an issue with the programs uninstaller if called from WMI.

Link to comment
Share on other sites

I'm seeing a new breed of uninstalls lately on the new stuff where they seemed to have changed something to do with the new InstallShield launch

I normally uninstall this way from a large array of uninstall names but i'm finding this method doesn't seem to work like it used to with the latest uninstall entries

For $UninstallLoop = 1 To $aUninstallList[0]
        If StringInStr($aUninstallList[$UninstallLoop], 'MsiExec.exe', 1) Then ; Check For MSI Uninstaller
            Sleep(200)
            $aUninstallList[$UninstallLoop] = StringReplace($aUninstallList[$UninstallLoop], "/I", "/X") ; Change I to X to force uninstall rather than change
            $PID = Run($aUninstallList[$UninstallLoop] & ' /qb /quiet /passive /norestart') ; Start uninstall process with switches to create $PID
            _ProcessWaitCloseRec($PID, 180) ; Uninstall by waiting for process to stop
            If @error < 0 Then MsgBox(64, 'Uninstall Failure', 'Failed Uninstall ' & $aUninstallList[$UninstallLoop])
            Sleep(1000)
            _WindowClose() ; Close any popup browser windows
        Else
            Sleep(200)
            If FileExists($aUninstallList[$UninstallLoop]) Then
                $PID = Run($aUninstallList[$UninstallLoop] & ' /s /S /sp- /silent /norestart /remove /q0 /uninstall') ; Start uninstall process with switches to create $PID
                _ProcessWaitCloseRec($PID, 180) ; Uninstall by waiting for process to stop
                If @error < 0 Then MsgBox(64, 'Uninstall Failure', 'Failed Uninstall ' & $aUninstallList[$UninstallLoop])
                Sleep(500)
                _WindowClose() ; Close any popup browser windows
            EndIf
        EndIf
        GUICtrlSetData($hProgress, $iUnInstallIndex)
        $iUnInstallIndex += 1
    Next

And it ignores them and goes straight past, which is why i was seeing if the code in the first post would do the trick

even this on its own via cmd fails to remove them

start /wait msiexec /qn /norestart /x {39337565-330E-4ab6-A9AE-AC81E0720B10}

something has changed and i cant put my finger on it yet

The programs and features is now just a link that points here

C:\Program Files\InstallShield Installation Information\{409370D3-226D-412A-852A-F134B89F7116}\Setup.exe

Which then removes the file.

I dont remember it being this convoluted before...

Link to comment
Share on other sites

The oddity with the new ones is

They work fine from Programs And Features

They work fine if you run setup.exe from the installshield folder

 

Its only when you automate them they resist

Link to comment
Share on other sites

Thanks for that Adam

So your saying i can no longer get away with just uninstall by name for these newer installshield ones like

$PID = Run($aUninstallList[$UninstallLoop] & ' /qb /quiet /passive /norestart')

Im going to have to create that around the setup.exe instead y?

$PID = Run('C:\Program Files\InstallShield Installation Information\{409370D3-226D-412A-852A-F134B89F7116}\Setup.exe' & ' /qb /quiet /passive /norestart') 

Thats just a mock up btw

Edited by Chimaera
Link to comment
Share on other sites

Your welcome.  Give it a shot, but it depends on how they setup the installer.  I have seen some that allows you to use MSI commands, and other that would not.  The most reliable way I have seen is to use an answer file, but I would try both to find out which works best for you.  

 

Adam

Link to comment
Share on other sites

If the installer has been done without the answer file can it still respond to one if i make an answer file for it?

And if it was the same proggie on a different brand machine would it still work with the same answer file?

Edited by Chimaera
Link to comment
Share on other sites

Yes, it will respond to an uninstall answer file.  It does not matter the brand of machine.  The answer file is basically an automation of the GUI interface, without interacting with the GUI directly when it is run using the answer file.  The only thing to remember, is the answer file will be different, if the developer changes the GUID between version or updates.  Here are some examples of a setup and uninstall answer files created for the ILLiad Client.  Your application answer files will be similar.  

setup.iss

[{40806BC2-67B3-4AF3-8D2C-50A11910CC72}-DlgOrder]
Dlg0={40806BC2-67B3-4AF3-8D2C-50A11910CC72}-SdWelcome-0
Count=5
Dlg1={40806BC2-67B3-4AF3-8D2C-50A11910CC72}-SetupType2-0
Dlg2={40806BC2-67B3-4AF3-8D2C-50A11910CC72}-SdAskDestPath-0
Dlg3={40806BC2-67B3-4AF3-8D2C-50A11910CC72}-SdStartCopy2-0
Dlg4={40806BC2-67B3-4AF3-8D2C-50A11910CC72}-SdFinish-0
[{40806BC2-67B3-4AF3-8D2C-50A11910CC72}-SdWelcome-0]
Result=1
[{40806BC2-67B3-4AF3-8D2C-50A11910CC72}-SetupType2-0]
Result=304
[{40806BC2-67B3-4AF3-8D2C-50A11910CC72}-SdAskDestPath-0]
szDir=C:\Program Files\ILLiad\
Result=1
[{40806BC2-67B3-4AF3-8D2C-50A11910CC72}-SdStartCopy2-0]
Result=1
[{40806BC2-67B3-4AF3-8D2C-50A11910CC72}-SdFinish-0]
Result=1
bOpt1=0
bOpt2=0

uninstall.iss

[{40806BC2-67B3-4AF3-8D2C-50A11910CC72}-DlgOrder]
Dlg0={40806BC2-67B3-4AF3-8D2C-50A11910CC72}-SdWelcomeMaint-0
Count=3
Dlg1={40806BC2-67B3-4AF3-8D2C-50A11910CC72}-MessageBox-0
Dlg2={40806BC2-67B3-4AF3-8D2C-50A11910CC72}-SdFinish-0
[{40806BC2-67B3-4AF3-8D2C-50A11910CC72}-SdWelcomeMaint-0]
Result=303
[{40806BC2-67B3-4AF3-8D2C-50A11910CC72}-MessageBox-0]
Result=6
[{40806BC2-67B3-4AF3-8D2C-50A11910CC72}-SdFinish-0]
Result=1
bOpt1=0
bOpt2=0

 

Adam

 

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