How do I shutdown, restart, or log off Windows via a bat file?

I've been using Remote Desktop Connection to get into a workstation. But in this environment, I cannot use the power options in Start Menu. I need an alternative way to shutdown or restart. How do I control my computer's power state through the command line?

6,919 3 3 gold badges 34 34 silver badges 48 48 bronze badges asked Oct 2, 2008 at 13:37 52.9k 32 32 gold badges 84 84 silver badges 111 111 bronze badges

10 Answers 10

The most common ways to use the shutdown command are:

The commands above can be combined with these additional options:

I want to make sure some other really good answers are also mentioned along with this one. Here they are in no particular order.