cannot uninstall a windows service: “…cannot be de

2020-07-06 07:06发布

I need to uninstall a Windows Service I have created, but I get this error using the "Uninstall or change program" program in windows:

Error. An exception occurred while uninstalling. This exception will be ignored and the uninstall will continue. However, the application might not be fully uninstalled after the uninstall is complete. -> The event log source '111 My Service' cannot be deleted, because it's equal to the log name.

Then I click "OK" and the program remains listed in the list of installed programs. What is worse, I cannot install a new version of it. The windows installer says that another version of this product is already installed and I should uninstall it first. How do I get rid of this program?

Update Here is what is happening when I run InstallUtil.exe /u command on it.

The uninstall is beginning. See the contents of the log file for the C:\MyService.MyService. assembly's progress. The file is located at C:\MyService.MyService.InstallLog. Uninstalling assembly 'C:\MyService.MyService.exe'. Affected parameters are: logtoconsole =
assemblypath = C:\MyService.exe
logfile = C:\MyService.MyService.InstallLog Removing EventLog source 111 My Service. An exception occurred during the uninstallation of the System.Diagnostics.EventLogInstaller installer. System.InvalidOperationException: The event log source '111 My Service' cannot be deleted, because it's equal to the log name. An exception occurred while uninstalling. This exception will be ignored and the uninstall will continue. However, the application might not be fully uninstalle l is complete.

The uninstall has completed. An exception occurred while uninstalling. This exception will be ignored and the uninstall will continue. However, the application might not be fully uninstalle l is complete.

4条回答
男人必须洒脱
2楼-- · 2020-07-06 07:45

Try to execute next command in cmd:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe /u "c:\myservice.exe"

The second option is:

sc delete <service name>

After running the line above you can try to remove the service branch as well in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services.

查看更多
啃猪蹄的小仙女
3楼-- · 2020-07-06 07:54

This just happened to me and the solution above didn't work where you run the InstallUtil.exe or delete the service. I had initially set up my service with the "LocalSystem" security context, and it was installed with that. I later changed the security context to "User" and recompiled the service executable and tried to uninstall the old service. The error messages were coming up that are described here, and once I went and changed the security context back to "LocalSystem" I could fully uninstall.

In other words, you might want to uninstall your old service with the executable it was created with rather than a newer one with possible modifications.

查看更多
做个烂人
4楼-- · 2020-07-06 07:54

The accepted answer didn't work for me.

What worked is open regedit in administrator mode and find the service and delete it.

查看更多
一纸荒年 Trace。
5楼-- · 2020-07-06 08:01

I had the exact same problem (and nothing in the selected answer worked).

Surprisingly, what fixed the problem was (using the standard "Uninstall or change program" or "Programs and Features" windows dialog) right-clicking on the program and choosing repair (this was apparently successful), and then uninstalling.

查看更多
登录 后发表回答