Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem installing windows service

I am having a problem installing a Windows service. I installed and uninstalled the service numerous times (installutil..... installutil /u) without any problem but something went wrong and now when I attempt to install, I get the error message listed below. I checked the computer management console, and service CIMediator does not appear on the list of services. How do I remove the service?

System.ArgumentException: Source CIMediator already exists on the local computer.

like image 205
user418676 Avatar asked Jan 28 '11 01:01

user418676


1 Answers

Just solved the same problem, also after a numerous uninstalls/installs/restarts. I have my own implementation of service installer (derived from [System.Configuration.Install.Installer][1]), and I have specified application EventLog as following:

    public ProjectInstaller()
    {
        InitializeComponent();

        EventLogInstaller installer = FindInstaller(this.Installers);
        if (installer != null)
        {
            installer.Log = "MyService";                 
        }
    }       

You might have the same feature implemented the following way ([MSDN: EventLog.CreateEventSource Method] [2]):

if(!EventLog.SourceExists("MySource"))
{
    EventLog.CreateEventSource("MySource", "MyNewLog");
}

In my case, during some of the installs EventLog was successfuly created, but during uninstall something went wrong, and EventLog was not removed (although it was not displaying in EventViewer, it was still present in the registry). So the error "MyService already exists on the local computer", was obviously error about EventLog, not the service itself.

You could try to do the following:

Go to your Start menu and type regedit. This will open Registry Editor. Be careful with it, it is always recommended to back up the whole registry before doing anything (File -> Export), or only the keys you are about to edit/delete. Open Edit -> Find , type CIMediator and leave only Keys checked. Your service name should appear as key multiple times, on following locations

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services\eventlog\CIMediator,
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services\CIMediator,
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\eventlog\CIMediator,
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\CIMediator

Try to delete these keys. It worked for me.

1 2

like image 84
rybers Avatar answered Dec 09 '22 07:12

rybers