Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

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)
Do
ProcessHandle = OpenProcess(ACCESS, False, ProcessId)
If ProcessHandle <> 0 Then
CloseHandle ProcessHandle
End If
DoEvents
Loop Until ProcessHandle = 0


End Sub
ASKER CERTIFIED SOLUTION
Avatar of nffvrxqgrcfqvvc
Commented:
This problem has been solved!
Unlock 1 Answer and 8 Comments.
See Answers