Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account

Creating an automatic uninstall script

  • Please log in to reply




  • Member
  • PipPip
  • 61 posts
Ok, this is my first attempt at anything other than a batch file. What i aim to create is a script that will automatically uninstall programs listed within the script.

The script i have is as follows:

Option Explicit 'all variables must be defined

Dim oReg, oShell, oFSO 
Dim UninstallString, ProductCode
Dim strComputer, colItems, objWMIService, objItem
Dim strKeyPath, subkey, arrSubKeys
strComputer = "." 

'Enter Product Code Of The Application Here That You Want To Uninstall within the Bracket 
ProductCode = "{AC76BA86-1033-0000-7760-000000000004}" 


' Get scripting objects needed throughout script.
Set oShell = CreateObject("WScript.Shell")

UninstallString = "MsiExec.exe /X" & ProductCode & " /qn" & " /norestart"

Const HKEY_LOCAL_MACHINE = &H80000002

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_ 
strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
For Each subkey In arrSubKeys 
 IF subkey = ProductCode Then 
 oShell.Run UninstallString, 1, True
 End If


Set oShell = Nothing
Set oReg = Nothing
'************* End Code ************

The script is a VBS (.vbs) script, The thing i'm having problems with is locating commonly removed programs (Limewire etc) and thier respective GUIDs, If a program does not have a GUID, i have this script as a fallback:

strApplicationName = "Name of Software Here"
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery("Select * From Win32_Product Where Name = '" & strApplicationName & "'")
For Each objSoftware in colSoftware

Anyone care to shed some light for me?
  • 0


Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP