I am writing a service, in which I want to restrict users from modifying service startup type. How do I do? I have attached a windows service which grays out the startup option.
Is "graying out" the real goal? Or is the intent to disable changing the startup type? The Win32 registry has fine-grained security. Just don't give users write access to the startup type.
Yes, the goal is to restrict user to modify the service startup type. For now, I know the key can be restricted so when user tries to modify the service startup it will show up error. But is there a way to gray out via API like restricting to control the service status (stop, start and pause)
AFAIK, there is no public API to allow a user service to grey out its startup type. Microsoft does that for their own system services so users don't mess up the OS. If you don't want users to stop/pause your service, you can handle that in your service code by omitting the SERVICE_ACCEPT_PAUSE_CONTINUE and SERVICE_ACCEPT_STOP controls when calling SetServiceStatus().
SERVICE_ACCEPT_PAUSE_CONTINUE
andSERVICE_ACCEPT_STOP
controls when callingSetServiceStatus()
.