Problem installing windows service
Asked Answered
L

2

11

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.

Leonardaleonardi answered 28/1, 2011 at 1:51 Comment(0)
K
21

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

Keynote answered 7/3, 2013 at 9:46 Comment(1)
Perfect solution. I did find keys generated in registry. I am sure i have not install it through Project Bin folder. Wonder how did it created registry key without installing. just curious.However, deleting existing keys did resolve my issue. Thank you.Michaelmichaela
V
0

Check to see if the key is still there in the registry.

HKLM\System\CurrentControlSet\Services\CIMediator (probably, unless the key is defined differently)

If it is, export the key to a .reg file and then delete it.

Vaunting answered 28/1, 2011 at 5:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.