Friday, November 14, 2008

Remotely Uninstall Software

At my company I set up and started using System Center Essentials 2007 a few months ago.

During that initial test (and what I believed was going to be our final configuration - this is before we did our domain rename and hosed it all up) I added desktops and servers to be monitored.

We renamed our domain and all of those servers and desktops had to have their SCE agent uninstalled and reinstalled.

Here's how I uninstalled the original agents so that they can be monitored again using the correct FQDNs:
  • I did a Google search for how to uninstall software remotely.  I came across the command "msiexec" which people use to install or uninstall programs on the local computer with a reference to the programs GUID.  I also found "psexec" (a sysinternal tool) that lets me execute commands on a remote computer.
  • I did another search for a VBS script to get the software install on the remote computer.  I needed one that gave me the GUID of the packages that were installed so I could pass it to msiexec.
  • I found one on Microsoft's site and created my VBS file.
  • I created a batch file that would be executed on the remote computers that used msiexec.
Here's what my batch file looked like ("uninstall SCE stuff.bat" to be precise :)):
msiexec.exe /norestart /qn /x {11447AB1-2B37-49D3-9963-2ACDFA06E04B} remove=all
msiexec.exe /norestart /qn /x {E7600A9C-6782-4221-984E-AB89C780DC2D} remove=all

If you look up the command line options for msiexec.exe you'll know what each of those options means.  Quickly though, the /norestart obviously causes a "no restart" (not that these packages require it...but just to be safe), the /qn does the uninstall quitely with no user interaction or windows, and the /x does the uninstall.  Also note the GUID after the /x (one for the "System Center Essentials Agent" and one for the "Configuration Helper").

On my desktop I issued the following command:
psexec \\remotecomputer -c "uninstall SCE stuff.bat"

After a few seconds the 2 packages were uninstalled.  I typed "\\remotecomputer\c$\Program Files" to get to the remote computer's "Program Files" and then deleted the "System Center Essentials 2007" folder.

I went back into the SCE console and attempted to reinstall the agents.  Boo yah!  Worked like a charm!

It's really nice being able to administer those kinds of things remotely so I don't have to bother my users!

No comments: