Video Screencast Help
Symantec Secure Login will be live on Connect starting February 25. Get the details here.

Uninstall an Application Using GUID from Registry

Created: 30 Nov 2010 | 6 comments
CableGuy41's picture
+22 22 Votes
Login to vote

I wrote this Visual Basic script when I came across a scenario where I know only the Application Name [As it is under Add/Remove  programs] and I need to uninstall the application based on application GUID.

Look at the example below:

I have to uninstall 7-zip but I don't know the uninstall string. In this scenario this script will find out the product GUID based on DisplayName and give you the uninstall string as output.


On error resume Next

Dim strName, WshShell, oReg, keyname

Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."

'Change the value here with DisplayName's value
strName = "InstallShield 2009"
Set WshShell = CreateObject("WScript.Shell")
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
 keyname = ""
    keyname = wshshell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & subkey & "\DisplayName")
 If keyname = strName then
  i = subkey
 End If

If i Then
 MsgBox "MSIEXEC.EXE /X " & i & " /QB!"
 'WshShell.Run "MSIEXEC.EXE /X " & i & " /QB!", 1, True
End If

Set WshShell = Nothing
set ObjReg = Nothing



Just change strname as indicated in the script. one you execute the script, it will prompt a message box with the complete uninstall string. But if you want to execute the uninstall then comment the message box ['MsgBox "MSIEXEC.EXE /X " & i & " /QB!"
] and remove the comment from WshShell.Run [ WshShell.Run "MSIEXEC.EXE /X " & i & " /QB!", 1, True].

If you want to execute the uninstall in silent replace QB! with QN.

You can edit the script and fine tune according to your requirement. Rename the attached text file to .VBS and execute.

Note: This script will uninstall based on application GUID. If you are trying to uninstall a legacy application [without GUID] or any application without a GUID, this script won't work. I will try to post a script soon which will uninstall using "UninstallString" registry key.

Download Filed Under:

Comments 6 CommentsJump to latest comment

CableGuy41's picture

Hi All,

My friends asked me to modify the script so that it should display a Input Message box which takes "Application Name" as input and display the output in a NOTEPAD so that they can easily copy that and uninstall immediately.

So i modified the script accordingly and one more change i've made in the script is the Application Name search. If the application name is "7-zip 4.65", the search can take only 7-zip [not case-sensitive] and display the result. I used InStr() in the script for comparision. You can change this script according to your requirement and let me know the feedback. I appreciate your time on this.

Note: Rename the attached text file to Uninstall_AnyApplication_ByName.vbs and execute

Uninstall_AnyApplication_ByName.vbs_.txt 1.96 KB


Do not forget to mark a SOLUTION

Login to vote
Praveeneds's picture

This script is simply awesome. For some reason i was working on a script that should uninstall the previous version application installed on the machine. But i don't know the product code. This script fetched me the Product Code after giving the application name as input. Wow! Thumbs Up!

Login to vote
JeffDG's picture

Nice script...very simple to use and can be deployed without any fuss!


Login to vote
Chaganti's picture

This will definitely comein handy :-)

Thanks & Regards,


Login to vote