Question Locked

How to trigger an uninstall from a program

0 helpful
15 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Is there a way to uninstall a program, using my own program? My program is coded in VB6.

Here is my scenerio, my program, basically runs off a series of visual installs and when needed, sends keyboard input and uses sendmessage to buttons and tabs when needed.

Occasionally some of the programs we install, such as MSXML4, will mysteriously stop working and start spewing stupid errors. The only fix is to uninstall them, restart the computer, then reinstall them.

The question is, how do I start the uninstall procedure from my program?

Essentially I need to be able to detect if MSXML and one other inhouse app is installed, and then fire the uninstaller.

How do I fire the uninstaller?

15 replies

by tony hopkinson

simply shell executing the setup exe and 'clicking' on remove, or the unistall shortcut, if it has one should be a goer.

You could be all over the place with the number and type of apps, you might be better off actually using installsheild or some such instead and then calling that from your app. You could get it to walk through the entire process.

by slayer_

Add/Remove programs some how knows where every uninstaller is located, how can I read that to figure out where MSXML is and to uninstall it. I would asume is should install to the same folder on every system.

by cg it

if you go into program files then find the program you installed program folder, inside will the the uninstaller. Depends on which installer program is used. There is a registry entry for it. That's how windows add/remove program knows which uninstall.exe to use. Think of the old Direct Access DOS program that uses batch files to execute the .exe to launch a program when a particular key is press on the keyboard. Same with uninstall. there is a .bat file to start the uninstall.exe program.

you can write an "if this then that" program which says if this condition exists, then to that which is executing a .bat file which runs the uninstall program. BUT! you never know what the little program might do. If the same condition exists for another program, that little program won't know it's only supposed to run for 1 particular program. It "might" cause all uninstaller programs to launch or confict with add/remove programs. It might leave registry keys behind which can cause problems with the system startup.

[I messed around with this for a while] Safest way is to manually uninstall the program.

by tony hopkinson

But you've seen one or two of them refuse to do it haven't you?. One or two that have said thy worked left some garbage on your drive or in the registry, that you had to clean up before you could re install.

Then there's UAC, if you are covering for Vista, Virtualisation...

It's a big tin of worms this one, and how well it goes depends on how good the installer is, not how good you are or could be.

Don't forget OS version, then depending on where you get your binaries from you could end up rolling back as a service pack or windows update patch...

If it's fairly simple then go right ahead, me I'd be trying to figure out how to fix the issue with MSXML, or may be use something else, SAX for instance, before I went too far down this path.

by tony hopkinson

If you can't get near total control, and be able to verify that the scenrio to wrote the process for is the one you've got. It's a world of hurt. You can easily end up in a state where you can't install or uninstall , or one where it goes on it's merry way ,and breaks something else.

I know I would not do it from my application, I'd be using one of the installer utilities, they are designed for it.

by slayer_

I don't see why there should be a problem. of course I will test this properly :). Thats what virtual machines are for. But eventually this will need to be tested on a live system.

by cg it

working rather than uninstalling themselves. The other mostly part of why programs just don't uninstall themselves is that there is the potential of screwing up the computer. For consumer level applications to the public, there is liability. The application screwed up the computer therefore the company that made it is liable for the damages.

While you can write a batch file for it, if it does mess up the computer, you'll have to do a recovery. If the program is simply an inhouse application, then you could try it, but if a users computer goes bad, they will point the finger at you.

by slayer_

It's amazing how often iTunes for example, locks on to our repository version of MSCOMCTL.OCX. Which buggers stuff up.

Not really our fault, they should be working harder, not listening to music and loading up their ipods.

by slayer_

But it is immedatly met with "But that change is a lot of work we can't do that right now"

As if the amount of time wasted webex'ing into clients machines and reinstallation this garbage.

Ideally we'd like to, appon getting the stupid error, schedule the reinstall to take place when they close our program.

by slayer_

Here is the uninstall command for MSXML4

uninstall cmd: MsiExec.exe /I{FB64BF25-3593-4E4E-AA85-84AEF1D1475F}

It's got a fricken GUID!

Alright, suggestions anyone?
I am guessing read the registry to find something called MSXML 4.0 SP2, dig down, find the GUID than construct the command?

by slayer_

Took some fidling, cause it requires the GUID to uninstall, but it has a listing function, so I list them to a text file, then read the text file searching for the name, then grab the GUID and use that. Works perfect (I think, I look forward to testing it on a user with the problem that this fixes)


Private Sub Step1()
Dim FM As New clsFileManager
Dim sCommand As String
Dim sCommand2 As String
Dim bFound As Boolean
Dim iLineNum As Integer
Dim sLineRead As String
Dim sKey As String
Const sMSXMLNAME As String = "MSXML 4.0 SP2 PARSER AND SDK"
Const sCANOSINAME As String = "CANOSISETUP (VERSION 1.0.0)"
'we need some lists of apps to uninstall, first one that has the name
'then one that has the GUID. Once we have the GUID, we can kill it properly.
sCommand = FM.ReadINI(INI, "Network", "Drive", "J:\")
sCommand = sCommand & "cfw32\Workstation Install\UninstallW.exe"
sCommand = Chr(34) & sCommand & Chr(34) 'surround path in quotes
sCommand2 = sCommand 'make copy at this point
'sCommand = sCommand & " /c >C:\cfw32\UninstallCommands.txt"
sCommand2 = sCommand2 & " /l >C:\cfw32\UninstallList.txt"

'now, run the commands
Call Processor.startDeterminedProcessing(0, 50, True, "Building list of uninstalls and their keys, please wait.", False)
frmDeterminedProcessing.Top = frmDeterminedProcessing.Top + 2000
'Call ExecCmd("cmd /C " & sCommand)
Call ExecCmd("cmd /C " & sCommand2)
'Call Processor.StopProcessing

'Now we search thru list 2, and find MSXML (Eventually for CANOSI aswell)
Call FM.OpenFile("C:\cfw32\UninstallList.txt", 1, False)

bFound = False
iLineNum = 0
Do Until FM.isEOF = True Or bFound = True
iLineNum = iLineNum + 1
sLineRead = FM.ReadLine(False)
If InStr(1, UCase$(sLineRead), sMSXMLNAME) Then
bFound = True
End If
Loop
Call FM.CloseFile(False)
'we got it, dbug the line number
Call dbug("Found MSXML, line number is: " & iLineNum)
'Parse the key out of it, it is indicated by the brackets
sKey = Left(sLineRead, InStr(1, sLineRead, "}"))
Call dbug("Key found is: " & sKey)

'Ok we got it, kill it
Call Processor.setMessage("Uninstalling " & sMSXMLNAME)
'Call Processor.startDeterminedProcessing(0, 50, True, "Uninstalling " & sMSXMLNAME, False)
'Call ExecCmd("cmd /C " & sCommand)
Call ExecCmd("cmd /C " & sCommand & " /q " & sKey)

This discussion is closed to new replies.