2
votes

I'm writing a small service in C# and I've installed it and uninstalled it a couple of times and all of a sudden it won't install again. I tried to uninstall it and it says there is nothing to uninstall, but when I install it again I get the following message:

Error 1001: The specified service already exists

Now, I've tried the following solutions:

  • Close the service manager (as an open service manager may hold a handle to it)

  • Tried to find it with SC QUERY and delete is using SC DELETE (according to Service already exists (when it clearly doesn't))

  • Tried to remove it in regedit (doesn't exist there)

  • I've correctly added the project output to Custom Actions (install, commit, rollback, uninstall)

  • Restarted the computer (!)

I'm running out of ideas. There is absolutely no proof that the service is installed on my computer and even though thousands of developers seems to have had this problem (and I've even had it myself previously) I've never heard of a situation where none of the standard solutions actually works.

What could I have missed?

EDIT

I've been into regedit and I tried again to find my service, but this time I exported the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ section and searched it. I can find my service in the dump under:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MyService

But then I go there in the regedit view, it's not there. Any suggestions? How did I screw that up :?

RE-EDIT

Disregard edit, the service only shows in regedit while the install i showing the error message, but that's event weirder, the service is installed, then breaks and rollbacks...

3
I had this a couple of times on XP but Win7 fixed the issue so far. In those cases it was either the EventLog-Viewer or the service manager. And a restart always cleared the issue. All I can say is that it might be important to uninstall with the old .exe but I don't know any possible solutions aside from trying a reg-cleaner tool.Random Dev
Well, I'm using Vista (the best operating system since win95!) and I'm not sure why a restart wouldn't solve it since it's not in the regedit...Maffelu
@CarstenKönig - I've just exported my entire registry and tried a find on 'MyService' in it, found nothing, so it is not in the registry...Maffelu
maybe not by name but maybe by some other entry (guid, whatever) - the only other "solution" I see would be to reinstall windows - don't think that this is better than trying a regcleanerRandom Dev

3 Answers

2
votes

As a temporary solution, you can change the name of the service slightly ( e.g. add or remove one or two chars from the service_name) but keep the display_name the same.

1
votes

I would suggest looking and Sysinternals Process Monitor activity and going backwards trying to find what happened before the error was reported. You might be able to see that for example a certain reg key was accessed.

0
votes

I had a similar issue to this (the service was in stopped state and then deleted by an overzealous disk space tidier) and to solve it I copied my new service to the same location as marked in the "Path to Executable" box, and then started the service.

No issues so far.