Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Uninstalling your uninstaller!!

Uninstalling your uninstaller!!

Scheduled Pinned Locked Moved C#
questiontutorial
11 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    exhaulted
    wrote on last edited by
    #1

    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

    C D 2 Replies Last reply
    0
    • E exhaulted

      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

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      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

      E 1 Reply Last reply
      0
      • C Colin Angus Mackay

        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

        E Offline
        E Offline
        exhaulted
        wrote on last edited by
        #3

        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

        C 1 Reply Last reply
        0
        • E exhaulted

          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

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #4

          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

          E 1 Reply Last reply
          0
          • C Colin Angus Mackay

            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

            E Offline
            E Offline
            exhaulted
            wrote on last edited by
            #5

            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

            M 1 Reply Last reply
            0
            • E exhaulted

              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

              M Offline
              M Offline
              Marc Clifton
              wrote on last edited by
              #6

              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

              E 1 Reply Last reply
              0
              • E exhaulted

                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

                D Offline
                D Offline
                Dennis C Dietrich
                wrote on last edited by
                #7

                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

                E 1 Reply Last reply
                0
                • M Marc Clifton

                  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

                  E Offline
                  E Offline
                  exhaulted
                  wrote on last edited by
                  #8

                  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 saying Cannot 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

                  M 1 Reply Last reply
                  0
                  • D Dennis C Dietrich

                    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

                    E Offline
                    E Offline
                    exhaulted
                    wrote on last edited by
                    #9

                    Thanks for your reply Dennis, i'm gonna see if i can get anything working with the registry entries first. Cheers Kev

                    1 Reply Last reply
                    0
                    • E exhaulted

                      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 saying Cannot 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

                      M Offline
                      M Offline
                      Marc Clifton
                      wrote on last edited by
                      #10

                      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

                      E 1 Reply Last reply
                      0
                      • M Marc Clifton

                        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

                        E Offline
                        E Offline
                        exhaulted
                        wrote on last edited by
                        #11

                        Lol, after all that you are right, you can just tell it to delete itself!!:laugh: I just assumed there woudl be file locking issues but there's not. Thanks to you all for your help. Kev

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups