ServiceController.start() and ServiceController.stop() are throwing exceptions?

前端 未结 5 1542
野趣味
野趣味 2021-01-21 07:43

The following code is throwing Exception. I don\'t get what mistake I am making in the code. Can somebody help me figure out please. I think it is of some security rights issue.

5条回答
  •  不思量自难忘°
    2021-01-21 08:21

    In my case, I determined that I needed to adjust the security on my service to allow it be be restarted by a separate "watchdog" service if my service fails.

    First, open mmc.exe, then add the "Security Configuration and Analysis" and Security Templates" snap-ins.

    enter image description here

    Then create a new blank security template from the "Security Templates" item, give it a name, and hit OK to save it on your local disk drive somewhere convenient.

    Then open "Security Configuration and Analysis" and choose "Open Database...", give it a name, and save it in the same directory as the previous step. When an "Import Template" window appears, open the *.inf file in the same directory.

    Next, right-click "Security Configuration and Analysis" and choose "Analyze Computer..." The following will appear:

    enter image description here

    Double-click on "System Services", locate and double-click on your service, then click the checkbox "Define this policy in the database" and click on the "Edit Security" button.

    This is where it becomes different than what is described in the link @JOG posted since I am using Windows 8.1--I enabled "start, stop and pause" for "INTERACTIVE" and "SERVICE"

    enter image description here

    FYI, I performed the above by following this guide as @JOG suggested: https://thommck.wordpress.com/2011/12/02/how-to-allow-non-admins-to-start-and-stop-system-services/

提交回复
热议问题