Click here to Skip to main content
15,889,335 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C#
The requirement of my project is to install and run my service as protected and uninstall this protected service.

I have tried implementing the protected anti malware service referring the following msdn post:

https://msdn.microsoft.com/en-us/library/windows/desktop/dn313124(v=vs.85).aspx

I have successfully installed the protected service with the help of ELAM as mentioned in the post. Now I want to uninstall this protected service. 

C#
Using the same protected service while uninstalling ChangeServiceConfig2 fails with error(5) Access Denied, when I try to set SERVICE_LAUNCH_PROTECTED_INFO from SERVICE_LAUNCH_PROTECTED_ANTIMALWARE_LIGHT to SERVICE_LAUNCH_PROTECTED_NONE, the service handle provided to this function has SERVICE_ALL_ACCESS rights.
How can we mark this service as unprotected with help of ChangeServiceConfig2 and uninstall the service?

What I have tried:

To uninstall this service we need to mark it as unprotected. We can mark this service as unprotected with help of registry by modifying "LaunchedProtected" value from 3 to 0 at registry path "HKLM\System\CurrentControlSet\Services\Test Service".
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900