Uninstalling .NET Windows Service using InstallUtil gives “marked for deletion error”

If you are working with a .NET-based Windows service and have trouble uninstalling it, the problem may be due to allowing it to interact with the desktop. I used the Services admin tool to change the service’s security context to Local System.  When I made that change, I also enabled “Allow service to interact with desktop.”  Later, after making some code changes, uninstalling the service failed.  To uninstall, I used

InstallUtil.exe /u <service>.exe

but the uninstall failed saying that the service is “marked for deletion.”  After trawling around a bit, I found this message in the event log:

“The [service name] service is marked as an interactive service.  However, the system is configured to not allow interactive services.  This service may not function properly.”

So, Windows Server 2008 R2’s local policy must default to disallow services to operate interactively.  I disabled “Allow service to interact…” and uninstall is working again.

BTW, allowing a service to operation interactively is not a good idea in the first place.  I was just going to use it for some output / debugging during development.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.