Most users turn off their computer using the button located in the Start menu. Some people use physical power buttons on their machines. Very few people use the method by which it is possible shut down computer from command line.

The reason for this is that most of us don't know that you can use the command line not only to shut down or log off, but also to shut down a remote computer if you have administrative access. With these privileges, you can send a message containing the reason for the shutdown. This post will show you how to do it.

Your first action will be... At the initial stage, do this using one of several methods:

  1. Press the Windows key (window icon) + R.
  2. In the Run window, type CMD and press OK with your mouse or Enter on your keyboard.

This will launch the command prompt. Follow the instructions below depending on what you want to do.

Shutting down the local computer (yours)

Here you will need one single shutdown command, but if you enter it in this form, you will not succeed. The command uses its own extensions, namely the S prefix, which indicates that the device is disabled.

Enter shutdown -s at the command prompt and press Enter, which will soon cause the PC to temporarily shut down with a warning. If you use shutdown -p, the computer will turn off instantly.

The peculiarity of shutdown is that the computer can be shutdown from command line after a certain amount of time. The command above is prefixed with t, a numeric variable, and becomes shutdown –s -t 300.

Once executed, a countdown timer starts and a warning message is displayed. The numeric variable (in this case 300) represents the number of seconds after which the computer will shut down. Set your number of seconds based on your needs.

To display a message containing the reason for shutdown, use shutdown –s -t 500 -c "I'm tired. I don't want to work, I'm going home"(with quotes) in cmd and press Enter key. The -c option is used in the command to comment out the reason for the shutdown and what follows in quotes will be displayed in the dialog box as an explanation. This can be used to display funny messages.

Shutting down a remote computer

To turn off the remote computer Type shutdown -s -m \\computer name in cmd and press Enter. Replace "\\computer name" with the actual name of the remote PC to attempt shutdown. As mentioned earlier, you must have administrator access to the computer you are trying to shut down. To find out if you have administrative access rights, press the Windows + R key combination, enter the computer name, then press the Enter key.

Note: If you don't remember the name of the remote computer, you can find it by opening a list of all connected PCs by running net view on the command line.


If you can connect to your computer, you will need to enter your username and password. Once you enter them, the window will display a list of all directories available to you. This should help you know whether you can or cannot shut down the remote computer.

Use an expression like "shutdown -a" to roll back a shutdown. This will stop the system shutdown, shutting down if the countdown has not reached 0.

That's all, I hope the lesson was useful and you already know how to shut down computer from command line. You should always remember that running as an administrator gives you privileges, and everything else is not too difficult to figure out!

35,421 Views

I had a task to organize the rapid shutdown of remote servers in one click. Moreover, various users must turn off servers, including those without knowledge and understanding of the principles of server operation. That is, they just have to press a button to have the server shut down automatically.

Moreover, you need to turn off both Windows servers and Linux servers of various distributions over the network - ubuntu, centos, freebsd. That is, the solution must be simple and reliable.

Remote shutdown of Windows server

Let's start with the most difficult one. In practice, implementing a reliable way to turn off Windows machines over the network turned out to be more difficult for me than Linux. There are many methods and approaches to solving this problem. I tried different options and settled on one that seemed the most reliable, it worked without problems in all cases during testing.

A prerequisite for remotely shutting down a server is network access to it via rdp. You can be on the local network with it, or forward the rdp connection by redirecting from the gateway. It doesn’t matter, the main thing is to get into the system via rdp.

The operating principle of remote shutdown is as follows:

  1. A user is created on the computer or server who will be allowed to connect via rdp and shut down the server.
  2. This user's startup will contain a shutdown script.
  3. Users who will shut down the server remotely are given a specially prepared rdp client, which, without any requests, will be connected by the desired user, for whom the shutdown script will be triggered.

Everything is quite simple, but at every stage I encountered problems that required a non-trivial solution. But first things first.

So, let's go north and create a simple bat file there with the following content:

Shutdown /p /d p:0:0 /f

We save the file and create a user under which we will shut down the server. Don't forget to add permission for this user to connect via rdp. If you turn off a computer with a desktop system, then the rights of a regular user are sufficient. If you need to turn off Windows Server, then you need to either make the user an administrator or give him the rights to allow him to turn off the server through the local security policy. This politician lives at the address - security settings - local policies - assigning user rights - shutting down the system.

This is where I ran into my first troubles. I named my script shutdown.bat and for a very long time I could not understand why it did not work. When entering the command shutdown everything worked fine with the parameters in the console, but the script did not run. It turns out that he cannot be called by that name. After I renamed it to shut.bat, everything worked fine. It's kind of a ridiculous snag, but it took me a long time to figure out what it was all about.

Next, we go to our new user so that standard profile folders are created and put the server auto-shutdown script in his startup - C:\Users\shut-user\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup.

Now we need to configure automatic user login via rdp to perform remote shutdown. Moreover, the user must log into the server without asking for a name and password. This cannot be done using standard Windows rdp client tools. Even if you save the settings, you will need to enter the password again when you transfer the settings to another computer. It didn't suit me.

I tried using an old ported version of rdp 5.2. This is the last version where the password could be stored encrypted in the settings file. But when I transferred this file to another computer, a password entry window still popped up. It was not possible to achieve complete automation.

But a solution was found. There is an interesting project called Remote Desktop Plus, which is an add-on to rdp. Using this add-on, you can pass parameters to rdp via the command line, including the username and password. This suits me completely. Download the file either from the project author’s website or from mine. I copied this very useful utility just in case. We put it in a folder and create it in the same folder rem-shut.bat file with the following content:

Rdp.exe /v:10.10.5.14 /u:shut-user /p:pass123 /w:640 /h:480

All this is enough to perform a remote shutdown on a Windows server. The user needs to transfer 2 files:

  • rdp.exe
  • rem-shut.bat

It is important that they are in the same folder. When you run the batch file, the user's rdp will be connected and the shutdown script will be executed. Mission accomplished.

Remote shutdown of Linux server

Here everything turned out to be much simpler. A working solution was immediately found that allows you to remotely shut down any Linux server without any problems. The problem is solved using standard putty tools. This program can be run from the command line with parameters. As parameters, you can specify a file with commands to execute, server address, user and password.

We will prepare everything you need. First, create a simple text document shutdown.txt the following content:

Putty.exe -m shutdown.txt -ssh -P 22 -l root -pw rootpass 10.10.5.15

We transfer 3 files to the user, placed in one folder:

  • putty.exe
  • shutdown.txt
  • serv-rem-shut.bat

Now, when you run the serv-rem-shut.bat script, a console command will be sent to the server over the network to shut down. No questions will be asked. The server will simply shut down silently.

Conclusion

These are the simple methods I came up with and implemented. It is also important to provide access to the local network in which the servers live. In my case, openvpn allows you to remotely shut down computers even over the Internet.

I'm sure there are many other options to extinguish the server remotely. I would be glad if someone would share their ideas and experiences on this matter with me in the comments.

Online course on Linux

If you have a desire to learn how to build and maintain highly available and reliable systems, I recommend that you get acquainted with online course “Linux Administrator” in OTUS. The course is not for beginners; to enroll you need basic knowledge of networks and installing Linux on a virtual machine. The training lasts 5 months, after which successful course graduates will be able to undergo interviews with partners. What this course will give you:
  • Knowledge of Linux architecture.
  • Mastering modern methods and tools for data analysis and processing.
  • Ability to select a configuration for the required tasks, manage processes and ensure system security.
  • Proficient in the basic working tools of a system administrator.
  • Understanding of the specifics of deploying, configuring and maintaining networks built on Linux.
  • The ability to quickly solve emerging problems and ensure stable and uninterrupted operation of the system.
Test yourself on the entrance test and see the program for more details.

To speed up your work on the computer, it is always useful to use shortcut keys, which save a lot of time. This applies not only to Windows XP and 7, but also to more modern products - Windows 10. Therefore, there are interesting ways to control the system via the command line. An interesting fact is that such an interface does not become obsolete even in Windows 10, since some things are still durable. In this article we will look at the issue of disabling the system through this command line, laconic in its design. The best part is that using this method you can turn off computers not only in the immediate vicinity, but also through remote controls.

You can use any specified time. Moreover, the method is so universal that it is suitable for all systems from XP to the 10th generation inclusive. Anyone can set up such a service, especially since such a shutdown is very popular for those people who often want to turn off the computer after watching a TV series or downloading movies before going to bed. It’s very convenient when you’ve been sleeping for a long time, and the system turns off itself at a given time.

Launch code

To turn off your computer through an interesting interface - the command line, you need to perform a series of sequential actions:

  • The first step is to run the command line on the system. It is usually indicated in searches as Cmd.

  • A window with a black background will open, where you need to type: shutdown /s /t 60. This code means that the computer will shut down in one minute.

As you might guess, the specified time is set by the sequence /t 60. There are other keys that help configure auto shutdown:

  • /L is an auto-logout followed by logging out of the current user.
  • /f is an auto shutdown followed by closing all running programs on the Windows system.

Remote shutdown

Automatic shutdown can also be configured through a computer remote control system. To do this you need to write another code:

  • shutdown /s /t 60 /f /L /m \\192.168.1.55

You can also enter the computer name after /m. For example, if the computer is called USER, then the code changes:

  • shutdown /s /t 60 /f /L /m \\USER

Platforms

This shutdown works in all versions of Windows: it could be the outdated Windows XP and the recently cherished hope for the perfection of Windows 10. The fact is that auto-shutdown through a modest interface - the command line - is a basic work with the system. There is no need to customize the graphical shell, there is no need to make the appearance fashionable and modern. A simple black window on the computer desktop perfectly solves all current problems if you know the basic codes. Therefore, it doesn’t matter whether XP or 10 is installed on the machine, the commands that are hardwired into the operating system kernel can be easily executed via the command line using the same methods as they were done before. By the way, time passes, and faster auto shutdown even in Windows 10 has not yet been developed.

(Visited 2,354 times, 1 visits today)

There are times when you need to turn off your computer after a certain time. For example, you turned on downloading a large file overnight, so as not to wait for the download to complete, you can set a countdown timer to turn it off. There are a huge number of programs and utilities on the Internet that perform similar tasks. Moreover, almost all torrent clients have a shutdown function after the download is complete. But I just gave you an example; at the time of writing this article nothing else came to mind.

So, first you need to call the command line. Press the key combination R

A command window will appear Execute, enter there cmd and click OK


A command prompt will appear, enter the following

shutdown /s/t 3600

Then press the Enter key

Where the number 3600 indicates the number of seconds before turning off, exactly seconds, not minutes.

1 hour = 3600 seconds
2 hours = 7200 seconds
3 hours = 10800 seconds

The above method is suitable for Windows 7 and Windows 8; for the Windows XP operating system, you need to specify a hyphen instead of a slash.

shutdown -s-t 3600

Yes, I almost forgot, it may also happen that you change your mind about turning off the computer or want to change the timer, then you just need to cancel the specified operation. We also write the following in the command line:

shutdown/a

and press the Enter key

If you want to learn even more about the capabilities of the utility built into the Windows operating system, then use the command line to call help. How to do this is below.

Usage: shutdown

xx:yy ]

No pairs. Display help. Same as with the /? parameter.

/? Display help. Same as without parameters.

/i Displays the graphical user interface.

This parameter must come first.

/l End the session. This option cannot be used with

parameters /m or /d.

/s Shuts down the computer.

system, launching all registered applications.

/a Cancels system shutdown.

This option can only be used during the waiting period.

/p Immediately shuts down the local computer without warning.

Can be used with the /d and /f options.

/h Switches the local computer into hibernation mode.

Can be used with the /f option.

/e Specifies the reason why the computer shut down unexpectedly.

/m computer Specifies the destination computer.

/t xxx Specifies a delay of xxx seconds before shutting down

computer.

Valid range: 0-315360000 (10 years); default value: 30.

If the timeout period is greater than 0, the

parameter /f.

/c "comment" A comment with the reason for restarting or shutting down.

The longest length is 512 characters.

/f Forces closure of running applications without warning users.

The /f option is used if the /t option

a value greater than 0 is specified.

/d xx:yy You must specify a reason for rebooting or shutting down.

"p" means scheduled reboot or shutdown.

"u" means the reason is user defined.

If neither "p" nor "u" is given, reboot or shutdown

are unplanned.

xx is the major reason number (a positive integer less than 256).

yy is the minor reason number (a positive integer less than 65536).

Reasons on this computer:

(E = expected, U = not expected, P = planned, C = determined

user)

Type Main Auxiliary Header

U 0 0 Other (Unplanned)

E 0 0 Other (Unplanned)

E P 0 0 Other (Planned)

U 0 5 Other faults: System not responding

E 1 1 Equipment: Maintenance (Unscheduled)

E P 1 1 Equipment: Maintenance (Planned)

E 1 2 Equipment: Installation (Unplanned)

E P 1 2 Equipment: Installation (Planned)

E 2 2 Operating system: recovery (planned)

E P 2 2 Operating system: recovery (planned)

P 2 3 Operating System: Update (Scheduled)

E 2 4 Operating System: Setup (Unscheduled)

E P 2 4 Operating System: Setup (Scheduled)

P 2 16 Operating system: Service pack installation (Planned

2 17 Operating System: Patch Installation (Unscheduled)

P 2 17 Operating System: Patch Installation (Planned)

2 18 Operating system: Installing a security patch (Unexpected

P 2 18 Operating system: Installing a security patch (Zapa

E 4 1 Appendix: Maintenance (Unscheduled)

E P 4 1 Appendix: Maintenance (Scheduled)

E P 4 2 Appendix: Installation (Planned)

E 4 5 Application: Not responding

E 4 6 Application: Unstable

U 5 15 System failure: STOP error

U 5 19 Safety problem

E 5 19 Safety problem

E P 5 19 Safety issue

E 5 20 Loss of network connections (Unplanned)

U 6 11 Power failure: Cable disconnected

U 6 12 Power failure: General problems

P 7 0 Crash caused by deprecated API function

Code: 6583079


It's no secret that nowadays a computer makes life a lot easier. It's easy to use and really helps save a lot of time searching for information. It is also often used for entertainment. Many people watch TV series, movies or play games. It often happens like this: you watch a movie on your computer, and after the final credits roll, you don’t want to get up and turn it off. Knowing special commands, you can avoid these operations. The computer can be set to auto-shutdown. via the command line will make watching movies more comfortable. This will explain the procedure, as well as a shortcut that acts as a shutdown button.

Shutting down the computer via the command line

Absolutely any user can do this. The shutdown computer command will help you with this. First, you need to enter the control line itself. To do this, click "Start", hover over "All Programs" and try to find "Accessories" there. When you click on it, the Windows menu will open in front of you, which can make your work easier. One of these programs - Open it, a black window will appear in front of you. This is what we are looking for. You can use it to control your computer. You can also turn off your PC or set it on a timer. In order to set it for a certain time, just enter the command “Turn off the computer” through the command line. You need to write the text shutdown in English letters. In English this translates as “close”. However, entering just this command is not enough. You need to additionally put "-" and the English letter "s". The entire code looks like this: "shutdown-s". Once you press Enter, the computer's shutdown button will work.

How to set your computer to auto shutdown via the command line?

Now we will talk about how to make your PC more convenient. It would be nice to do it yourself after some period of time. This can also be done via the command line. You need to enter it through “Start” / “All Programs” / “Accessories” / “Command Prompt”. Next, in the open black window, you enter the same command as for shutdown - “shutdown-s”. But you need to add an entry to it that the computer should be turned off not now, but after some time, that is, add “-t” separated by a space. This will let the computer know that it should turn off after a certain time. Next, you should specify the time in seconds after which your computer should shut down. Let's say that by writing "shutdown -s -t 10", wait for it to shut down in ten seconds. If you write shutdown -s -t 6000, the computer will be turned off after 100 minutes. We would like to remind you that 10 minutes before the end of work, a window with the remaining time will appear on the screen. If you wish to cancel the shutdown, you can do so. You can see how to carry out this action below in the article.

How to cancel turning off your computer?

If you needed to put your PC on a timer, but then you changed your mind and do not need this action, you need to enter the code “shutdown -a” at the command line. After this, the previous operation will be canceled and you can continue working.

Computer shutdown shortcut

Agree, it is convenient if you can turn off the computer from the icon on the desktop. You don't need to go into "start-up-shutdown" every time. Simply clicking on the icon will trigger shutdown. You can do this yourself and it won't take much of your time.

How to create a shutdown shortcut?

If you decide to create a shortcut to turn off your computer, there are a few steps you need to follow. You will succeed if you follow the instructions. To do this, on an empty space on the desktop, right-click to open it and select “Create”. Next, click on “shortcut”. A simple icon will be created on your desktop. After its formation, a window will pop up with the question “For which element do you need to create a shortcut?” It will have an input line called “specify the location of the object.” In it you need to write text similar to the control words for turning off the computer via the command line. But it will be a little different. The command will look like this: Shutdown.exe -s -t 00. After entering the command, press Enter. Next you have to name the folder. You can call it “turning off the computer” or something else - whatever is convenient or whatever you like. Click the "Finish" button and the folder is created. You can also change the icon for this shortcut. Right-click on it, then select "Properties". Go to the "Shortcut" section and at the bottom you will see "Change Icon". Click, select the one you like, click “Save” and “Done”. Place this symbol separately from the others so that you don’t accidentally turn off your PC later. We hope this article helped you understand what the shutdown command is and how to create a shortcut for it.