Question Help with Uninstall

ALX

Well-known member
Joined
Nov 16, 2005
Messages
253
Location
Columbia, SC
Programming Experience
10+
I'm writing a small app to run during "Uninstall" to delete all Files & Directories that were set up / created by my main application when it was installed and during it's use. The delete statement;
VB.NET:
My.Computer.FileSystem.DeleteDirectory("MainProgramDirectory", FileIO.DeleteDirectoryOption.DeleteAllContents)
fails, I assume because the Uninstall .exe itself has been loaded from within the same directory that I'm trying to delete. (Err.Description = ...'Being used by another process')... I'm wondering if there's a way to override or sidestep Window's behavior to disallow access and force the delete. I suppose I could put the uninstall pgm in a different directory, but that would still leave the uninstall app on the disc.
 
You don't need to delete the files and folders created during the installation. That's exactly what the uninstaller is for. It's the files and folders created AFTER the installation that won't get removed automatically, so they are the only ones that you need to remove manually.
 
what about an msi package to install in the first place?

a msi install package would be the cleanest way to deploy/uninstall the app in the first place.
is that a possibility in the future?

for now tho...deleting a file in use by the program that is using it...that's a tuffy!
found this on codeproject - perhaps it may help.
How To Make Your Application Delete Itself Immediately - CodeProject

http://www.advancedinstaller.com/ - freeware msi builder.

BTW - i took your post to mean you have an uninstaller already and that you are trying to clean up some other stuff, rather than creating an uninstaller. please clarify.
 
Last edited:
I am a poor SOB so I'm using "Inno Setup Compiler" which of course is freeware. It's flexible, easy to use and best of all, it's free. One option that Inno allows is the ability to run an app during uninstall. I guess I was trying to keep it simple by trying to delete everything with one statement. Apparently I'll need to loop through all of the files & directories and try to delete each individually and hope that Inno's uninstall will handle everything that wasn't deleted in that step. I find Microsoft's OS very often reports that files cannot be deleted because they are in use, even though they aren't. These flagged files stay locked up until rebooting. I understand the security behind this... I wish there was a way to inform the OS that these files really are not in use or that it's OK to override.
... 'Cool trick on that CodeProject link !...
 
Last edited:
so it sounds like your inno setup compiler creates an uninstall - check to see what that actually leaves behind before you worry about clean up.
if your app shows up in add/remove (or even it it doesn't) after install, check this reg area to see if there is a guid or other folder that matches your product.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
If you can find your product after install, most likely there is an uninstall string that you can simply invoke. i.e. here's one for an msi.
UninstallString -> MsiExec.exe /I{963BFE7E-C350-4346-B43C-B02358306A45}
You can simply put that in start->run and it would wipe out that program.
Here's another for cutePDF on my machine -
UninstallString - C:\Program Files (x86)\Acro Software\CutePDF Writer\Setup64.exe /uninstall
Not an msi, but it will invoke the setup exe with the proper cmd line switch.

I would investigate this kind of stuff, run the "default" uninstall and then worry about what else needs to be cleaned.
 
Back
Top