Is it possible to Shut down a local pc with group policies programatically through .net application?

StackOverflow https://stackoverflow.com/questions/998200

  •  14-09-2019
  •  | 
  •  

Question

I have a local application running with an user than have a group policy indicating this user can’t shutdown the pc.

And then I use your code, but when I ask by user and password to impersonate my app. I received the next error

System.Management.ManagementException: it’s not possible to use the user’s credentials for the local connections

Regards

Was it helpful?

Solution

I would try using the Process.Start() overload that allows one to supply a username and password. I would execute shutdown.exe on that new process.

Of course, storing the username and password is not terribly secure and could probably be hacked by anyone that wanted to spend enough time with it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top