Showing posts with label Winzip and PowerShell. Show all posts
Showing posts with label Winzip and PowerShell. Show all posts

Friday, January 20, 2012

Uninstall Software using PowerShell

 

Hi,

today i was trying to uninstall the the software using PowerShell.

i See few blog posts about uninstalling software using PowerShell they re recommending WMI to uninstall software using the .Uninstalled() method. But i think this method is not right because it don’t un-installed the software properly. Sometime uninstalling software using these method cause system/laptop to crash.

In my view, un-installation should be done by proper way.

Lets un-install winzip in a proper way. You can also script it.

we are going to use WMI but in another way.

Lets Start

lets see installed software first using the below command.

Get-WmiObject -Class win32_product

it is showing the list of all installed software.

 20-01-2012 17-24-32

Now see if we have winzip installed. we are piped the previous command to Where-Object and searching for name which contain winzip in it.

Get-WmiObject -Class win32_product | where { $_.Name -like "*Winzip*"}

Yes we have WinZip installed

20-01-2012 17-27-40 

Lets pipe the above command to Format-List to that we can see all the members of the Winzip.

Get-WmiObject -Class win32_product | where { $_.Name -like "*Winzip*"} | format-List *

This will give us  all the member properties of Winzip. The property in which we are interested is “LocalPackage”

20-01-2012 17-31-01

and you can see that install LocalPackage contains a path to a .msi executable file. and we can uninstall .msi files uisng MSIEXEC. lets check the which command line switches MSIEXEC support.

Simple run MSIEXEC and it will show you all the switches msiexec support.  The switch which we are going to use is /x and /passive

20-01-2012 17-38-01

lets combine the all commands together. I put the first command in to $Wzip variable.

  1. $Wzip = Get-WmiObject -Class win32_product | where { $_.Name -like "*Winzip*"}
  2. $Wzip.localPackage

Now try to run $Wzip.localPackage and this will show us the WinZip install source

20-01-2012 17-43-54 

Run the below command to uninstall the Winzip.

msiexec /x  $wzip.localpackage /passive

this will start un-installation of Winzip and will show only the Progress bar only {because we are using msiexex’s /passive switch”

Here it start uninstallation .

20-01-2012 18-05-01 

20-01-2012 18-05-38 

20-01-2012 18-05-44 

20-01-2012 18-06-37 

All done !!!! lets check Programs and features in Control Panel and winzip is not here :)

20-01-2012 18-11-05 

 

You are save all this in script and use it to uninstall winzip or any other software using powershell.

Hope it helps someone :)

 

Thanks

Aman Dhally