- Shut down the system
- Reference
- Possible values
- Best practices
- Location
- Default values
- Operating system version differences
- Policy management
- Group Policy
- Security considerations
- Vulnerability
- Countermeasure
- Potential impact
- Команда Shutdown: выключение и перезагрузка Windows из командной строки
- Выключение Windows командой Shutdown
- Перезагрузка Windows
- Завершение сеанса пользователя
- Перевод компьютера в режим гибернации
- Перезагрузка компьютера с сообщением пользователям
- Отложенное выключение / перезагрузка компьютера
- Отмена выключения / перезагрузки компьютера
- Перезагрузить компьютер немедленно
- Запуск команды shutdown на удаленных компьютерах
- Графический интерфейс команды shutdown
- Ярлык для перезагрузки компьютера
- shutdown
- Syntax
- Parameters
- Remarks
- Examples
Shut down the system
Applies To: Windows Vista, Windows Server 2008, Windows 7, Windows 8.1, Windows Server 2008 R2, Windows Server 2012 R2, Windows Server 2012, Windows 8
This security policy reference topic for the IT professional describes the best practices, location, values, policy management, and security considerations for this policy setting.
Reference
This security setting determines if a user who is logged on locally to a computer can shut down the operating system by using the Shut Down command.
Shutting down domain controllers makes them unavailable to perform functions such as processing logon requests, processing Group Policy settings, and answering Lightweight Directory Access Protocol (LDAP) queries. Shutting down domain controllers that have been assigned operations master roles (also known as flexible single master operations or FSMO roles) can disable key domain functionality; for example, processing logon requests for new passwords, which is performed by the primary domain controller (PDC) emulator master.
The Shut down the system user right is required to enable hibernation support, to set the power management settings, and to cancela shutdown.
This policy setting is supported on versions of Windows that are designated in the Applies To list at the beginning of this topic.
Possible values
A user-defined list of accounts
Best practices
Ensure that only Administrators and Backup Operators have the Shut down the system user right on member servers, and that only Administrators have the user right on domain controllers. Removing these default groups might limit the abilities of users who are assigned to specific administrative roles in your environment. Ensure that their delegated tasks will not be negatively affected.
The ability to shut down domain controllers should be limited to a very small number of trusted administrators. Even though a system shutdown requires the ability to log on to the server, you should be very careful about the accounts and groups that you allow to shut down a domain controller.
Location
GPO_name\Computer Configuration\Windows Settings\Security Settings\Local Policies\User Rights Assignment
Default values
By default this setting is Administrators, Backup Operators, Server Operators, and Print Operators on domain controllers, and Administrators and Backup Operators on stand-alone servers.
The following table lists the actual and effective default policy values for the most recent supported versions of Windows. Default values are also listed on the policy’s property page.
Server type or GPO
Default Domain Policy
Default Domain Controller Policy
Stand-Alone Server Default Settings
Domain Controller Effective Default Settings
Member Server Effective Default Settings
Client Computer Effective Default Settings
Operating system version differences
There are no differences in the way this policy setting works between the supported versions of Windows that are designated in the Applies To list at the beginning of this topic. However, the setting is not compatible with computers running Microsoft WindowsВ 2000 Server with Service Pack 1 or earlier.
Policy management
This section describes features, tools, and guidance to help you manage this policy.
A restart of the computer is not required for this policy setting to be effective.
Any change to the user rights assignment for an account becomes effective the next time the owner of the account logs on.
Group Policy
Do not apply this setting to computers running Microsoft WindowsВ 2000 Server with Service PackВ 1 or earlier.
This user right does not have the same effect as Force shutdown from a remote system. For more information, see Force shutdown from a remote system.
Settings are applied in the following order through a Group Policy Object (GPO), which will overwrite settings on the local computer at the next Group Policy update:
Local policy settings
Site policy settings
Domain policy settings
OU policy settings
When a local setting is greyed out, it indicates that a GPO currently controls that setting.
Security considerations
This section describes how an attacker might exploit a feature or its configuration, how to implement the countermeasure, and the possible negative consequences of countermeasure implementation.
Vulnerability
The ability to shut down domain controllers should be limited to a very small number of trusted administrators. Although the Shut down the system user right requires the ability to log on to the server, you should be very careful about which accounts and groups you allow to shut down a domain controller.
When a domain controller is shut down, it is no longer available to process logon requests, process Group Policy settings, and answer Lightweight Directory Access Protocol (LDAP) queries. If you shut down domain controllers that possess operations master roles, you can disable key domain functionality, such as processing logon requests for new passwords, which is performed by the PDC master.
For other server roles, especially those where non-administrators have rights to log on to the server (such as RD Session Host servers), it is critical that this user right be removed from users that do not have a legitimate reason to restart the servers.
Countermeasure
Ensure that only the Administrators and Backup Operators groups are assigned the Shut down the system user right on member servers, and ensure that only the Administrators group is assigned the user right on domain controllers.
Potential impact
The impact of removing these default groups from the Shut down the system user right could limit the delegated abilities of assigned roles in your environment. You should confirm that delegated activities are not adversely affected.
Команда Shutdown: выключение и перезагрузка Windows из командной строки
Утилита командной строки shutdown является встроенной командой Windows, которая позволяет перезагрузить, выключить компьютер, перевести его в спящий режим или завершить сеанс пользователя. В этой инструкции мы покажем основные примеры использования команды shutdown в Windows (все рассмотренные команды запускаются в окне Выполнить — Win+R ->, в командной строке cmd.exe или в консоли PowerShell).
Команда shutdown имеет следующий синтаксис:
shutdown [/i | /l | /s | /sg | /r | /g | /a | /p | /h | /e | /o] [/hybrid] [/soft] [/fw] [/f] [/m \\компьютер][/t xxx][/d [p|u]xx:yy [/c «комментарий»]]
Как вы видите, у команды довольно много опций, а также есть возможность выполнять операции выключения/перезагрузки на удаленном компьютере.
Выключение Windows командой Shutdown
Для выключения ОС Windows и компьютера необходимо использовать команду shutdown с ключом /s.
Перезагрузка Windows
Чтобы перезагрузить компьютер, необходимо добавить параметр /r. После выполнения этой команды Windows корректно перезагрузится.
Завершение сеанса пользователя
Чтобы завершить текущую сессию пользователя (logout), нужно выполнить команду:
Эта команда аналогично выполнению команды logoff.
Перевод компьютера в режим гибернации
Для перевода компьютер в режим гибернации (в этом режиме все содержимое памяти записывается в файл hyberfil.sys на диск и компьютер переходит в спящий режим с пониженным электропотреблением), выполните команду:
Перезагрузка компьютера с сообщением пользователям
Вы можете предупредить всех пользователей Windows о предстоящем выключении / перезагрузки компьютера или сервера, отправив сообщение во все активные сессии (как правило эта возможность используется на терминальных RDS серверах, за которыми одновременно работают несколько пользователей, каждый в своей собственной RDP сессии).
shutdown /r /c “Этот сервер будет перезагружен через 60 секунд.”
Отложенное выключение / перезагрузка компьютера
Можно выключить или перезагрузить компьютер с определенной задержкой (по таймеру). С помощью опции /t можно указать интервал времени (в секундах), через который ПК/сервер будет перезагружен или выключен. Тем самым вы можете предоставить пользователям дополнительное время для того, чтобы успеть сохранить открытые файлы и корректно закрыть приложения. Эту опцию удобно использовать совместно с отправкой сообщения. В этом примере мы указываем, что Windows будет выключена через 10 минут (600 секунд) и информируем пользователей сообщением.
shutdown /s /t 600 /c «Сервер будет выключен через 10 минут. Сохраните свои документы!»
Пользователю будет выдано предупреждение о запланированном выключении: Ваш сеанс будет завершен.
Если задержка очень длительная, например, 100 минут (6000 секунд), то вместо предупреждающего окна появляется всплывающее сообщение в нижнем правом углу экрана: «Ваш сеанс будет завершен. Работа Windows будет завершена через 100 мин».
Отмена выключения / перезагрузки компьютера
После запуска команды выключения или перезагрузки Windows, по умолчанию утилита shutdown ожидает 60 секунд, не выполняя никаких действия. Администратора может отменить перезагрузку или выключение устройства, если в течении этого времени успеет выполнить команду:
После отмены выключения появится всплывающее сообщение в нижнем правом углу экрана: «Выход из системы отменен. Запланировано завершение работы отменено».
Перезагрузить компьютер немедленно
Чтобы выключить или перезагрузить компьютер немедленно, не ожидая стандартные 60 секунд, нужно указать значение 0 для параметра /t. Например, для немедленной перезагрузки компьютера:
Очень важный ключ /f. Я использую его практически всегда при выключении или перезагрузки серверов Windows. Данный атрибут обеспечивает принудительное завершение всех запущенных программ и процессов, не ожидая подтверждения от пользователя (не будем же мы ждать подтверждения закрытия программ от всех пользователей на терминальном сервере, его можно просто не дождаться).
Следующая команда выполнит перезагрузку компьютера с автоматическим запуском всех зарегистрированных приложений после перезагрузки (имеются в виду приложения, зарегистрированные в системе с использованием функции API RegisterApplicationRestart).
Запуск команды shutdown на удаленных компьютерах
Вы можете перезагрузить удаленный компьютер по сети, для этого у вас должен быть к нему сетевой доступ, а учетная запись, из-под которой запускается команда shutdown должна входить в группу локальных администраторов на удаленном компьютере (сервере):
shutdown /r /t 120 /m \\192.168.1.100
Если все указанные условия выполняются, но при выполнении команды shutdown появляется ошибка ”Отказано в доступе (5)”, на удаленном компьютере нужно разрешить удаленный доступ к административным ресурсам (C$, ADMIN$), изменив значение параметра LocalAccountTokenFilterPolicy на 1.
reg add «HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System» /v «LocalAccountTokenFilterPolicy» /t REG_DWORD /d 1 /f
Если вам необходимо удаленно перезагрузить множество компьютеров, их список можно сохранить в текстовый файл и запустить удаленную перезагрузку всех компьютеров с помощью такого PowerShell скрипта:
$sh_msg = «Ваш компьютер будет автоматически перезагружен через 10 минут. Сохраните свои файлы и закройте запущенные программы»
$sh_delay = 600 # секунд
$computers = gc C:\PS\PC-list.txt
foreach ($comp in $computers)
<
& ‘C:\Windows\System32\SHUTDOWN.exe’ «-m \\$comp -r -c $sh_msg -t $sh_delay»
>
Графический интерфейс команды shutdown
Для тех, кому не комфортно работать в командной строке, есть графический интерфейс для команды shutdown, чтобы его вызвать, наберите:
Как вы видите, в диалоге удаленного завершения работы вы можете добавить несколько компьютеров, которые нужно перезагрузить/выключить, указать текст уведомления и задать причину выключения для сохранения в журнале Windows.
Ярлык для перезагрузки компьютера
Для удобства пользователей вы можете создать на рабочем столе ярлыки для выключения или перезагрузки компьютера с нужными настройками. Такой ярлык может быть полезен для выполнения перезагрузки из RDP сессии, когда отсутствуют кнопки перезагрузки/завершения работы компьютера в меню Пуск.
Если вы хотите, чтобы ваш компьютер или сервер всегда выключался / перезагружался в определенное время, вы можете добавить команду shutdown с определенными параметрами в планировщик заданий Windows taskschd.msc.
Например, следующее задание планировщика будет ежедневно перезагружать компьютер ночью в 0:00.
shutdown
Enables you to shut down or restart local or remote computers, one at a time.
Syntax
Parameters
Parameter | Description |
---|---|
/i | Displays the Remote Shutdown box. The /i option must be the first parameter following the command. If /i is specified, all other options are ignored. |
/l | Logs off the current user immediately, with no time-out period. You cannot use /l with /m or /t. |
/s | Shuts down the computer. |
/sg | Shuts down the computer. On the next boot, if Automatic Restart Sign-On is enabled, the device automatically signs in and locks based on the last interactive user. After sign in, it restarts any registered applications. |
/r | Restarts the computer after shutdown. |
/g | Shuts down the computer. On the next restart, if Automatic Restart Sign-On is enabled, the device automatically signs in and locks based on the last interactive user. After sign in, it restarts any registered applications. |
/a | Aborts a system shutdown. Effective only during the time-out period. To use /a, you must also use the /m option. |
/p | Turns off the local computer only (not a remote computer)—with no time-out period or warning. You can use /p only with /d or /f. If your computer doesn’t support power-off functionality, it will shut down when you use /p, but the power to the computer will remain on. |
/h | Puts the local computer into hibernation, if hibernation is enabled. You can use /h only with /f. |
hybrid | Shuts down the device and prepares it for fast startup. This option must be used with the /s option. |
/fw | Combining this option with a shutdown option causes the next restart to go to the firmware user interface. |
/e | Enables you to document the reason for the unexpected shutdown on the target computer. |
/o | Goes to the Advanced boot options menu and restarts the device. This option must be used with the /r option. |
/f | Forces running applications to close without warning users. Caution: Using the /f option might result in loss of unsaved data. |
/m \\ | Specifies the target computer. Can’t be used with the /l option. |
/t | Sets the time-out period before shutdown to xxx seconds. The valid range is 0-315360000 (10 years), with a default of 30. If the timeout period is greater than 0, the /f parameter is implied. |
/d [p | u:] : | Lists the reason for the system restart or shutdown. The supported parameter values are:
|
NOTE
If p or u aren’t specified, the restart or shutdown is unplanned.
Remarks
Users must be assigned the Shut down the system user right to shut down a local or remotely administered computer that is using the shutdown command.
Users must be members of the Administrators group to annotate an unexpected shutdown of a local or remotely administered computer. If the target computer is joined to a domain, members of the Domain Admins group might be able to perform this procedure. For more information, see:
If you want to shut down more than one computer at a time, you can call shutdown for each computer by using a script, or you can use shutdown /i to display the Remote Shutdown box.
If you specify major and minor reason codes, you must first define these reason codes on each computer where you plan to use the reasons. If the reason codes aren’t defined on the target computer, Shutdown Event Tracker can’t log the correct reason text.
Remember to indicate that a shutdown is planned by using the p parameter. Not using the p parameter, indicates that the shutdown was unplanned.
Using the p parameter, along the reason code for an unplanned shutdown, causes the shutdown to fail.
Not using the p parameter, and only providing the reason code for an planned shutdown, also causes the shutdown to fail
Examples
To force apps to close and to restart the local computer after a one-minute delay, with the reason Application: Maintenance (Planned) and the comment «Reconfiguring myapp.exe», type:
To restart the remote computer myremoteserver with the same parameters as the previous example, type: