none
Uninstalling a windows service RRS feed

  • Question

  • Hi all,

    I'm having a odd little problem installing a windows service that I've developed. I recently upgraded from vs 2003 to vs 2005. I uninstalled the service as normal using the add / remove programs application. Now everytime I attempt to re-install the service I get the following message:

    "Source SMS AutoAlert Service already exists on the local computer" 

    The real problem is that the service "appears" to be uninstalled at this stage.

    Here's what I've done to try and solve this:

    1.  Used the command installutil /u "sms autoalert service" (result: says the service does not exist)

    2. Used the command sc delete "sms autoalert service" (result: says the service does not exist)

    3. Deleted "HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/sms autoalert service"  from the registry

    I still can't install the service. I get the same message as above. I never had this problem when using 2003. It installed/uninstalled services a million times. What's going on here? Any ideas why the installer thinks the service remains installed?

    Any help would be ace!

    Thanks
    Stuart

    Monday, May 15, 2006 11:14 AM

Answers

  • Did you ever get this resolved?  I found that it is not the service that it thinks still exists, it is the eventLog.source that still exists.  I have even created a new event log and new source and it still thinks the source should be the name of the service class.  I changed the name of the service and all references to it and it installed fine.  The key is to remove the source.  But I can't figure out how to do that since the DeleteEventSource method does not do the trick.  Any new info on this would be great.

     

    David

    Wednesday, August 22, 2007 5:41 PM

All replies

  • sc delete <service_name>

    in command prompt

    Thursday, June 15, 2006 1:49 AM
  • Did you ever get this resolved?  I found that it is not the service that it thinks still exists, it is the eventLog.source that still exists.  I have even created a new event log and new source and it still thinks the source should be the name of the service class.  I changed the name of the service and all references to it and it installed fine.  The key is to remove the source.  But I can't figure out how to do that since the DeleteEventSource method does not do the trick.  Any new info on this would be great.

     

    David

    Wednesday, August 22, 2007 5:41 PM
  • I am also having this same issue. I too am using an evenlog, and the source is the same as the name of the service.

     

    The thing that I don't understand is that this message is happing on install. What does the installer know about any event logs that my service might or might not create? The service is not yet executing.

     

    It seems this is a common problem. It is unfortunate that there seems to be almost no information around concerning it.

     

    Tuesday, November 27, 2007 5:55 AM
  • Remember to rename the service the Program.cs file as well.  That could potentially cause an installation issue and I think it will compile just fine.

    I have gotten past the problem I had.  I was finally able to get rid of the offending event source.  There were other issues as well, however.  Services are very touchy and I found that making very small incremental changes, then trying the install is the way to track what's killing it, at least in the beginning stages of development.  There is really not much useful information if the install fails.  That is true also if anything fails that is in the load or onStart method.  They can cause the service to become un-uninstallable.  They get marked for deletion and I found I have to reboot to get rid of them.
    Tuesday, November 27, 2007 3:23 PM
  • I had a similar problem. I removed the registry key at \HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\<my app name> and was able to re-install.

     

    • Proposed as answer by regularroutine Tuesday, January 15, 2013 8:47 AM
    Friday, February 8, 2008 8:12 PM
  • I had the same problem.   I think I got into the mess by changing the name of my source in my service.

    Reading through these replies...and a lot of experimenting...I finally found the following worked for me.

    1) open regedit and search for your event log source name.   (hope you named it uniquely)
    I found my source name in 2 places....
    \HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\<my service name>
    and
    \HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Eventlog\<my service name>

    2) note the file that the log is writing to...make a note of its name and path.
    3) Delete the keys found in step 1
    4) reboot (I couldn't delete the log file without reboot)
    5)  find the log file noted in step 2 and delete it.

    Strangely enough....when I now look at my Custom Event Log in the registry (the step 1 keys) ...the sources listed are the service source I created but also the event log name is listed as a source....hmmm
    Good Luck!


    • Edited by m244014 Tuesday, July 22, 2008 3:43 PM Added extra info
    • Proposed as answer by DragonNet Wednesday, May 26, 2010 11:12 PM
    Tuesday, July 22, 2008 3:36 PM
  • Hey

    I ran into the same problem over and over again. I could delete the registry entries and reboot as many times as I want, but still the same error.
    According to this post here:
    http://msdn.microsoft.com/en-us/library/system.diagnostics.eventlog.sourceexists.aspx
    the installer for the Service already tries to add an EventLog Source for you with the name of the Service. I actually tried to create the source with the same name in a custom action for this (and yes, in my code I check if the source already exists).
    I suspect that the my action is executed first, which would add the EventLog Source and after that the installer itself tries to create the same Source without checking if it already exists first.

    To prove my theory I changed the Name of the service (but not my EventLog Source Name in the code). It installed fine without errors and I could then find a new EventLog Source under "Eventlog/Application" in the registry that I did not ask for! So, I'd say this is not only the case for Windows Vista but for other OS's as well.

    I used a custom Log as well, maybe that is part of the problem.

    So, if you want to use a custom log for an eventlog source that has the same name as the service: don't do it (or at least don't create it in a custom action on installation time).

    Hope that helps anybody else out there to keep their sanity (I've lost most of mine by now).
    Thursday, November 26, 2009 9:48 AM