Hi need to shut down my computer using c# and i have tried this code :

Process.Start("shutdown","/s");

but the problem is that this code forces all running application to close
like if i am having an opened document in notepad this code will close the notepad without saving and i don't want that to happen
Thank you

Might I suggest using the API and P/Invoke to initiate a shutdown of the PC rather than another process. This should also give you better control over it.

P/Invoke Link

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.