troubleshooting Question

How to use VBA to uninstall a program with msiexec.exe

Avatar of darbid73
darbid73Flag for Germany asked on
Microsoft AccessVisual Basic ClassicInstallation
8 Comments1 Solution964 ViewsLast Modified:
I am trying to imitate the uninstalling of a program with VBA to save the user doing it.

The program is a plugin so it only has an unistall shortcut with the following target.  It is the google earth plugin.

"C:\WINNT\system32\msiexec.exe /x {2862C000-331E-11DF-89BF-005056806466} FEEDBACK=1"

This creates a User interface and as far as I can see the FEEDBACK=1 opens up a website at the end.

If I change the target to (as you would know /qn should just make it silent)

"C:\WINNT\system32\msiexec.exe /x {2862C000-331E-11DF-89BF-005056806466} FEEDBACK=0  /qn"

and then double click the button then it uninstalls silently as expected and nothing else happens.  Files/Directory and registry is clean after a while.

The problem is when I use the code below - then after it is uninstalled windows restarts. After the restart the files are gone and registry is clean but the directories are still there.

Could anyone give me a hint why this happens when I call the command from shellandwait????

Or is there are log that says which program forced XP to restart?

EDIT:I think I might have found out that it closes down if the GEPlugin.exe is still a process.  It appears that it does not end immediately - so maybe the answer to this question is how to get access to check if the process is running?

Call shellAndWait("C:\WINNT\system32\msiexec.exe /x {2862C000-331E-11DF-89BF-005056806466} FEEDBACK=0  /qn", vbHide)

'my shell and wait looks like this

Public Sub shellAndWait(ByVal strProg As String, _
ByVal lStyle As VbAppWinStyle)

Dim ProcessId As Long
Dim ProcessHandle As Long
Const ACCESS As Long = &H100000

ProcessId = Shell(strProg, lStyle)
ProcessHandle = OpenProcess(ACCESS, False, ProcessId)
If ProcessHandle <> 0 Then
CloseHandle ProcessHandle
End If
Loop Until ProcessHandle = 0

End Sub

Open in new window

Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros