I'm writing a C# application to automate a couple of common server admin tasks, and one of the tasks that I want to automate is shutting down or restarting the server (because a number of other applications have to be stopped in a certain order, and its a pain to do).
What the best way to invoke tasks on a server? What is the SAFE approach to server and service shutdown?