Service already exists (when it clearly doesn'

2020-02-10 03:46发布

问题:

I'm trying to create an installer for a Windows Service I developed. This installer has a custom UI at one point and it's the first time I do something like that so I installed and uninstalled the service a few times to make sure everything was like I wanted to in the installer.

Now my issue is that when I try to install the service, it fails with Error 1001: Specified service already exists, but the service is listed nowhere in the registry, the services.msc console, or by sc query.

Can anyone give me a clue of what's happening and how to fix it? Thank you

Edit: Thanks for your replies. I re-opened the management console and restarted the computer and am still getting the error. Changing the ProductCode and UpgradeCode did not fix the issue either. There's also absolutely no reference to the service in the registry.

回答1:

Run in command line:

sc delete service_name

Service names with spaces must be quoted.

Update: Try this:

sc query type= service > services.txt

and verify that the service does not appear with another name.



回答2:

if you try to remove a service when it's still running, it's marked as deleted so you won't see it in the list of services but any attempt to add a service with the same name will fail afterward. the easy solution is to restart. this way windows removes the service before login or you can remove it from Registry in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services

be careful with that



回答3:

http://www.winvistatips.com/windows-service-wont-uninstall-t535569.html

Have you closed and re-opened the management console? Also restarting your comp might help. Sometimes a service gets marked for uninstall and doesn't really finish until one of the two things listed above happen.

This has happened to me before and generally one of these two things fixed it.



回答4:

Some time when we install windows service from setup then also problem arises like we can not uninstall. here i will discuss few steps which solve this problem to remove install application entry from Add/Remove panel and again we can install the same application.

Open registry by Regedit and To locate the program's uninstall key, navigate to the following sub-folder:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall

select Uninstall icon and start find your program by name. when it will appear then just remove that entry from registry. after remove the program name will not display in Add/Remove. problem will be solved and again user can install the same application. i got this tips from this location http://eugene2k.hubpages.com/hub/How-to-force-uninstall-a-program and i tested and it worked.

The below steps is for how to remove services when service is not starting or file missing or corrupted.

1- Open cmd as administrator

sc delete servicename

2- open run > regedit , back it up first and then browse to

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services

and delete the service key

3- remove the folder where win service was installed

4- reboot the machine