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

前端 未结 5 1578
野趣味
野趣味 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条回答
  •  萌比男神i
    2021-01-21 08:22

    GetServiceHandle requires some access rights. If it works when you run it as an Admin user, but not as a normal user, then maybe this article can help.

    It clearly shows you how to manually give a Windows User rights to start and stop services (or set other permissions):

    http://thommck.wordpress.com/2011/12/02/how-to-allow-non-admins-to-start-and-stop-system-services/

提交回复
热议问题