Uninstalling your uninstaller!!
-
Hi folks, I've written a custom installer / uninstaller for my application and everything works fine :-) But... How do i delete my uninstal.exe?? I can't tell it to delete itself but i have been told there is a way to get windows to delete a file next time it starts up. Anyone got any ideas on how to do this? Kev
-
Hi folks, I've written a custom installer / uninstaller for my application and everything works fine :-) But... How do i delete my uninstal.exe?? I can't tell it to delete itself but i have been told there is a way to get windows to delete a file next time it starts up. Anyone got any ideas on how to do this? Kev
I think what you need is the RunOnce registry key. What happens is that your uninstall will create an entry under the RunOnce registry key and when the machine is next re-booted the command given in RunOnce will be run. The command you give can delete the uninstall.exe for you. MSDN Docs for RunOnce[^] Does this help?
My: Blog | Photos | Next SQL Presentation WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
-
I think what you need is the RunOnce registry key. What happens is that your uninstall will create an entry under the RunOnce registry key and when the machine is next re-booted the command given in RunOnce will be run. The command you give can delete the uninstall.exe for you. MSDN Docs for RunOnce[^] Does this help?
My: Blog | Photos | Next SQL Presentation WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
Very close but not quite. Assume i have installed my application and there is a file called
c:\uninstall.exe
Uninstall.exe is registered with the windows add / remove programs. The user tries to remove my application and all files and registry entries are deleted without any problems. All except one, Uninstall.exe. I can't tell it to delete itself as it is currently running and would obviously crash. Anyone know the answer or able to point me in the direction of an article? Kev -
Very close but not quite. Assume i have installed my application and there is a file called
c:\uninstall.exe
Uninstall.exe is registered with the windows add / remove programs. The user tries to remove my application and all files and registry entries are deleted without any problems. All except one, Uninstall.exe. I can't tell it to delete itself as it is currently running and would obviously crash. Anyone know the answer or able to point me in the direction of an article? Kevexhaulted wrote: Very close but not quite. What was wrong with my suggestion? Why not put the delete command in to the RunOnce registry key?
My: Blog | Photos | Next SQL Presentation WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
-
exhaulted wrote: Very close but not quite. What was wrong with my suggestion? Why not put the delete command in to the RunOnce registry key?
My: Blog | Photos | Next SQL Presentation WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
-
I wasn't aware that i could put commands into the registry. Could you show me how ot do it using the c:\Uninstall.exe as an example? Thanks for your help Kev
Colin pointed out the link to help. Here's the pertinent line: The data value for a key is a command line. Use a command line command, like "del", as in "del c:\uninstall.exe" Remember good ol' DOS? Marc MyXaml Advanced Unit Testing YAPO
-
Hi folks, I've written a custom installer / uninstaller for my application and everything works fine :-) But... How do i delete my uninstal.exe?? I can't tell it to delete itself but i have been told there is a way to get windows to delete a file next time it starts up. Anyone got any ideas on how to do this? Kev
exhaulted wrote: How do i delete my uninstal.exe? Check out: Win32 Q&A (MSJ 01/1996)[^]. It's an older article but I think it's an interesting approach (at least if you're not afraid of P/Invoking ;-)). Now, I haven't checked out if you can use this technique in managed code, but if not you can at least create a helper executable to take care of the final deleting. Best regards Dennis
-
Colin pointed out the link to help. Here's the pertinent line: The data value for a key is a command line. Use a command line command, like "del", as in "del c:\uninstall.exe" Remember good ol' DOS? Marc MyXaml Advanced Unit Testing YAPO
Marc, Thanks for clearing that up, that's the "Idiot Proof" answer i was after but... When i create my key with the value of
del c:\uninstaller.exe
i just get a message sayingCannot find del...
when i restart my PC. I assume i am missing something very trivial and i'll probably kick myself when i get it sorted but can you tell me what i'm doing wrong. Does the registry entry's name have to be anything specific? oir is that irrelevant in this case? Cheers Kev -
exhaulted wrote: How do i delete my uninstal.exe? Check out: Win32 Q&A (MSJ 01/1996)[^]. It's an older article but I think it's an interesting approach (at least if you're not afraid of P/Invoking ;-)). Now, I haven't checked out if you can use this technique in managed code, but if not you can at least create a helper executable to take care of the final deleting. Best regards Dennis
-
Marc, Thanks for clearing that up, that's the "Idiot Proof" answer i was after but... When i create my key with the value of
del c:\uninstaller.exe
i just get a message sayingCannot find del...
when i restart my PC. I assume i am missing something very trivial and i'll probably kick myself when i get it sorted but can you tell me what i'm doing wrong. Does the registry entry's name have to be anything specific? oir is that irrelevant in this case? Cheers Kevexhaulted wrote: Cannot find del... when i restart my PC. Ew. I had assumed that it would be able to run DOS commands. You might need to do something like c:\uninstaller /u, where you pass a command line parameter to itself. BTW, it won't crash if you tell it to delete itself--why would it? The running version is in memory. There is the potential, though, of a locking issue--a running app might have its file locked by the OS, but I'm not sure. Strange stuff! Marc MyXaml Advanced Unit Testing YAPO
-
exhaulted wrote: Cannot find del... when i restart my PC. Ew. I had assumed that it would be able to run DOS commands. You might need to do something like c:\uninstaller /u, where you pass a command line parameter to itself. BTW, it won't crash if you tell it to delete itself--why would it? The running version is in memory. There is the potential, though, of a locking issue--a running app might have its file locked by the OS, but I'm not sure. Strange stuff! Marc MyXaml Advanced Unit Testing YAPO