Скрипт для завершения работы windows

Загрузить PDF

Загрузить PDF

Блокнот — это бесплатный текстовый редактор системы Windows, которым можно пользоваться для редактирования программных кодов. В Блокнот можно ввести некоторые простые команды Windows, чтобы создать файл, запуск которого приведет к выключению компьютера. Создайте такой файл, чтобы быстро выключать компьютер или просто пошутить над кем-то.

  1. Step 1 Откройте Блокнот.

    Эта бесплатная программа для редактирования текста включена во все версии Windows. В Блокноте можно написать простейший код, который выключит компьютер.

    • Чтобы открыть Блокнот, нажмите «Пуск» > «Программы» > «Стандартные» > «Блокнот». Также можно нажать «Пуск», ввести блокнот и нажать Enter.
  2. Step 2 Введите shutdown.exe -s на первой строке.

    Это команда выключения компьютера.

  3. Step 3 Добавьте таймер с помощью параметра -t.

    По умолчанию компьютер выключится через 30 секунд. Чтобы изменить это время, добавьте параметр -t, а затем введите число секунд.

    • Например, чтобы компьютер выключился через 45 секунд, введите shutdown.exe -s -t 45.
    • Чтобы компьютер выключился немедленно, введите shutdown.exe -s -t 00.
  4. Step 4 Добавьте сообщение.

    Чтобы перед тем, как компьютер выключится, на компьютере отобразилось сообщение, используйте параметр -c. В нашем примере введите shutdown.exe -s -t 45 -c "текст сообщения". Текст нужно заключить в кавычки.[1]

    • Например, в сообщении можно указать, в течение какого времени компьютер выключится; для этого введите shutdown.exe -s -t 45 -c «Компьютер выключится через 45 секунд».
  5. Step 5 Нажмите «Файл» > «Сохранить как».» src=»https://www.wikihow.com/images_en/thumb/5/5b/Shut-Down-a-Computer-Using-Notepad-Step-5-Version-2.jpg/v4-460px-Shut-Down-a-Computer-Using-Notepad-Step-5-Version-2.jpg» width=»460″ height=»347″ loading=»lazy»></p>
<div class= Картинка с сайта: ru.wikihow.com

Файл нужно сохранить в формате BAT (пакетный файл), запуск которого приведет к выключению компьютера.

  • Step 6 Откройте меню «Тип файла» и выберите «Все файлы (*.

    *)». Теперь можно изменить тип файла.

  • Step 7 Удалите расширение .txt в конце имени файла.

    Вместо него введите .bat.

    • Если расширение (в виде трех букв) не отображается, в сети найдите информацию о том, как это сделать.
  • Step 8 Сохраните файл.

    Будет создан файл с расширением .bat; значок этого файла будет отличаться от значка текстового файла.

  • Step 9 Запустите созданный файл, чтобы выключить компьютер.

    Процесс выключения произойдет в соответствии с правилами, которые вы задали.

    • Перед тем как выключить компьютер, сохраните открытые файлы.

    Реклама

  • Предупреждения

    • Если вы решили над кем-нибудь подшутить, делайте это на свой страх и риск. Помните, что на вас могут обидеться или рассердиться.

    Реклама

    Об этой статье

    Эту страницу просматривали 85 547 раз.

    Была ли эта статья полезной?

    With this little two-line batch script, you can simply shut down a computer with a Windows operating system:

    @echo off
    %SYSTEMROOT%\system32\shutdown.exe -s -t 0

    To use the script, just create a new blank plain text file, copy the 2 lines into it and change the file extension from «txt» to «bat».

    When you then double-click on this file, the computer will be automatically shut down without demand.

    Useful Extensions to the Script

    Of course, we can already use the script presented exactly as it is written there. Nevertheless, depending on your needs, you can also make some modifications and extensions to the script to get even more out of it. We would like to take a look at what is possible and how it works in these following sections:

    • Embedding in other Scripts
    • Delayed Computer Shutdown
    • Restart Computer
    • Put Computer into Hibernation or Sleep Mode
    • Treatment of open Programs and Files
    • Withdraw Command
    • Change Command
    • Manual Restart
    • User Notifications
    • List of Parameters
    • Background Information
    • Alternative Writings

    Embedding in other Scripts

    This script can be used, for example, within large batch script files requiring a long processing time. For example, batch files in which many actions are performed or a big number of programs are started and executed.

    If you want the computer to be shut down automatically after the script has been processed, it is sufficient to add the second line from the example code to the end of the long batch script as the last line. This saves the user from having to wait in front of the computer for the script to finish, as the computer will automatically shut down once the work is done, so that you do not have to care about the shutdown anymore for yourself.

    Delayed Computer Shutdown

    The 0 respectively the last parameter in the command indicates that the shutdown should be performed within 0 seconds — that means, immediately and without any time delay. Using a different number there, makes the computer shut down with a delay, as for example this call shows:

    %SYSTEMROOT%\system32\shutdown.exe -s -t 180

    Here we pass «-t 180», which means that we switch off the PC after 3 minutes (3 x 60 seconds after calling the command). By the way, the letter «t» stand for «time» here.

    The specification of the time must always be given as an integer in seconds. A maximum value of 315360000 (10 years) can be used. If we omit specifying a time (i.e. if we just write «shutdown.exe -s» without any time specification), a t-value of 30 is assumed by default, meaning the computer shuts down after half a minute.

    Aside from that, it is also important to note that the time definition is always to be understood in the form of something like a «countdown» and not in the form of an absolute time. This means that if, for example, we give the command that the computer should be shut down in one hour (3600 seconds) at 5:00 p.m., the computer will only actually be shut down at 6:00 p.m. if the computer is kept switched on the whole time remained. However, if the computer goes into standby in the meantime, let’s say at 5:10 p.m., the countdown for the shutdown is also stopped and only resumes after the computer has been switched on again. We should keep this in mind, especially when defining longer periods of time.

    Restart Computer

    The parameter «s», which we have used in all of our previous examples so far, stands for the word «shutdown». Even if the program name «shutdown.exe» does not immediately suggest it, we can also use the same program to restart our computer either immediately or after an arbitrary period of time defined by the «t» parameter. The only thing we have to change in the command that we have learned so far is to replace the parameter «s» with «r». The letter «r» stands for «restart».

    %SYSTEMROOT%\system32\shutdown.exe -r -t 0

    With this call to «shutdown.exe» we restart our computer immediately after calling the command. Of course, we can also work with a time delay this time, as the next example shows:

    %SYSTEMROOT%\system32\shutdown.exe -r -t 60

    Again we can define any time between 0 and 315360000 seconds using the (time) parameter «t». In the example, we let the computer restart exactly after 60 seconds respectively after one minute.

    Put Computer into Hibernation or Sleep Mode

    So far we have looked at the command line parameters that we can use to either shut down or restart our computer. However, beyond that, Windows can also be put either into its hibernation state or in its sleep mode to save energy but also to be able to quickly resume an existing session. These states can also be activated using a script and are useful, for example, if after executing a long script we want to continue at the same point where we left off with all open programs and files.

    The parameter to hibernate our computer is «h». Unfortunately, this parameter cannot be used in the same way as we have previously seen for «s» (shutdown) or «r» (restart). Furthermore, there is no shutdown parameter for the sleep mode available at all, so we have to proceed completely differently to activate that state.

    Since activating these states is correspondingly more complicated and would take up too much space within this tutorial, I have written a separate tutorial about activating Windows hibernation and sleep mode using a script, in which we can go into more detail than it is possible here in only one paragraph.

    Treatment of open Programs and Files

    When running a command to shut down our computer automatically, inevitably, the question arises what actually happens if we still have applications or files open at the time the shutdown should take place. The answer to this question depends on the one hand on our time delay specified via the parameter «t», on the other hand we can also consciously control the behavior by using the parameter «f» (which we have not yet introduced). In this section we would like to take a look at how this works in detail.

    Basically, if the computer is switched off, two different things can happen: Either all programs are automatically closed without any prompt and unsaved changes to files are lost, or the user is given the opportunity to save unsaved files before shutting down or restarting by displaying a message before shutting down that programs with unsaved changes are still open.

    Which of these two cases occurs depends on our call. The following table provides an overview of the different cases that can occur:

    Command Action
    shutdown -s Immediate shutdown without asking or waiting
    shutdown -s -t 0 Inquiry «Open Programs» / «Waiting for Program» / «Unsaved Changes»
    shutdown -s -t 60 Immediate shutdown without asking or waiting
    shutdown -s -f -t 0 Immediate shutdown without asking or waiting

    If we use shutdown.exe without any other parameter such as f or t, an automatic shutdown occurs without further inquiry. This means that in this case, unsaved files would be lost. The same applies if a time delay of at least one second has been defined via the t parameter (if we call «shutdown -s» without specifying t, a time delay of 30 seconds is used by default so that t is also over 0 in this case). If, on the other hand, we define an immediate shutdown without any time delay using «-t 0», a query about the unsaved files occurs by default, so that saving is still possible at the last moment. If we want to prevent this, we can additionally pass the parameter f (force stop). If this parameter is set, «-t 0» will also cause an immediate shutdown without any inquiry. For t > 0, f is automatically set and cannot be deactivated.

    I tested these calls on various computers with Windows 11, Windows 10, Windows 7 and Windows XP. Windows 11, Windows 10 and Windows 7 behaved as described in my tests. Windows XP, on the other hand, only closed programs with unsaved files without further inquiry if «f» was explicitly set. The other systems always implicitly assumed «f» to be set as soon as t was greater than 0. Unfortunately, shutdown.exe does not know any other parameter to override this behavior in order to retain the storage option even in the event of a delayed shutdown or restart.

    Although we always used the parameter «-s» (shutdown) for the example calls shown in the table, «-r» (restart) behaves the same way.

    Withdraw Command

    The (time) parameter «t» can be used to define very long waiting times until the computer is shut down or restarted. As already mentioned above, a time delay of up to ten years is possible. Only after this time has elapsed the initiated shutdown (-s) or restart (-r) will be carried out. But what can we do if, within this possibly year-long period of time, we change our mind after some time has passed and we want to withdraw the command?

    The developers of «shutdown.exe» thought of exactly this case and gave us the parameter «a» (abort). The following example shows how we can use this parameter to cancel our scheduled action:

    %SYSTEMROOT%\system32\shutdown.exe -a

    Accordingly, we simply have to call «shutdown.exe» with the sole parameter «a». This will delete the planned shutdown or restart. The «a» parameter works regardless of which of these two actions we have scheduled.

    Of course, this command only works if it is called within the time period defined by «t» and not afterwards. If we have called «shutdown.exe» with «-t 0» (immediate execution), it is always too late to abort. If, on the other hand, we have started the program with «-t 60» (60 seconds), for example, and we issue the command to abort after, for example, 30 seconds, it is not too late and the automatic shutdown or restart can still be prevented.

    Change Command

    Also if we want to change the time delay of an already scheduled shutdown, we must first call the command «shutdown.exe -a» before we can define a new time via «shutdown.exe».

    Let’s assume that we have set the shutdown time to 180 seconds from now on and now we would like to retrospectively reduce this time to just 60 seconds. One might now perhaps expect that we could simply overwrite the command by setting another time again. However, if we would use the following sequence of commands, the second command would fail because the shutdown is already set to 180 seconds and the timer is already running. Despite this second call, a shutdown would nevertheless take place only after 180 seconds.

    %SYSTEMROOT%\system32\shutdown.exe -s -t 180
    %SYSTEMROOT%\system32\shutdown.exe -s -t 60

    It would be correct like this:

    %SYSTEMROOT%\system32\shutdown.exe -s -t 180
    %SYSTEMROOT%\system32\shutdown.exe -a
    %SYSTEMROOT%\system32\shutdown.exe -s -t 60

    Here we first define a time of 180 seconds for our shutdown again. However, to delete this command, the first thing we need to do is to call «shutdown.exe -a» like we have seen in the last section. Only then we can define a new time for the shutdown (here «shutdown.exe -s -t 60»).

    Manual Restart

    Another way to «withdraw» or «undo» the shutdown command is to manually shut down or restart the computer before the time for the automatic action has been reached. Once we do this, any system shutdowns or reboots scheduled via shutdown.exe will be automatically deleted.

    User Notifications

    If we use one of the commands presented here to instruct our computer not to shut down or restart immediately, but only after a certain time delay, the countdown that has been started with this, does not just run in the background in secret. Instead, the user is given various messages during the expiring time period, which can differ depending on the length of time delay as well as the Windows version used. In general, these notifications become more intrusive the closer we get to the shutdown time.

    • For short time periods of less than 3 minutes, immediately, a small dialog window appears announcing the shutdown.
    • For time periods between 3 and 10 minutes, two small dialog windows are shown. The first dialog immediately announces the shutdown in X minutes, the second dialog reminds you again 2 minutes before the shutdown.
    • If the time delay exceeds 10 minutes, there is first a notification about the shutdown in the tray, then a further warning 10 minutes before the shutdown and, depending on the system, another dialog 2 minutes before the shutdown.

    On some versions of Windows, the last dialog box before shutdown showed a countdown of the remaining time in the tests, on other versions of Windows only the time was displayed without any count down.

    List of Parameters

    Finally, we would like to summarize all the parameters used in this tutorial as well as some other useful parameters in the following list. By clicking on «Details» you can jump to the relevant section within this tutorial where the parameter in question is described and you can find examples of how to use the parameter.

    Parameter Meaning
    -s (shutdown) Shuts the computer down. Details
    -r (restart) Restarts the computer. Details
    -h (hibernation) Puts the computer into hibernation state. Details
    -l (logout) Logs out the current user.
    -a (abort) Cancels the shutdown or restart. Details
    -t x (time) Ensures that the shutdown or restart is carried out only after x seconds. If this parameter is omitted, the action occurs after 30 seconds by default. 0 leads to an immediate execution, a maximum value of 315360000 (10 years) can be used. Cannot be used with -h. Details
    -f (force stop) Use this parameter to force potentially active applications to close without warning. Unsaved changes to files can be lost. If t is greater than 0, the -f parameter is automatically applied. Details
    -i (interface) Shows a graphical user interface that allows you to configure the shutdown manually.

    Shutdown.exe knows a few other parameters in addition to the parameters listed in this compilation, but these are not required for the purposes described here. For example, the parameter «c» (comment) can be used to define a comment regarding the restart or shutdown, or the parameter «d» can be used to specify a reason for the restart or shutdown. If you would like to find out more about these and other parameters, you can simply use the command line call «shutdown -?». With this command, shutdown.exe prints a list of all possible parameters directly to the command line. Please note that the available parameters may differ depending on the Windows version used.

    Background Information

    Our script calls the program shutdown.exe, which initiates the shutdown respectively the restart process of Windows and which can also be used to put the computer into sleep mode. This program is located in the subdirectory «system32» of the Windows folder (typically this results in the path «C:\Windows\System32»).

    However, since the system folder can have a different absolute path on each computer (depending on where Windows has been installed), instead of using the mentioned absolute path, we use the constant «%SYSTEMROOT%» instead, which always gives us the correct folder for the respective system installation of the computer on which the command is executed. After all, it would be conceivable that someone has not installed Windows on the C: drive or that the folder differs from an older Windows version to future Windows versions.

    Alternative Writings

    Usually, Windows finds the program «shutdown.exe» even without specifying a path. This allows us to shorten the command (here for an immediate shutdown) to the following line:

    shutdown -s -t 0

    Furthermore, the parameters can also be passed with a slash instead of the hyphen used in most of the examples. With this, the command mentioned would look like this:

    shutdown /s /t 0

    Generally, all of the options mentioned should work, regardless of whether you use the hyphen or the slash and regardless of whether you define the full path or not. If in doubt and to be on the safe side, you should of course try out the command on the computer on which the script is to run before using it productively.

    Batch File Shutdown Commands – How To Shutdown, Reboot And Logoff

    In this article, you will learn about different commands and ways to shut down, reboot, and log off the PC. You will learn about batch file shutdown commands in detail.

    Batch file shutdown commands

    How to shutdown computer using cmd/batch file?


    The command used to shut down computer is

    shutdown /s /f /t 0

    Shut down computer using cmd

    Follow these steps to shut down the computer using cmd.

    • Run the command prompt
    • Type the above command and hit enter

      shutdown computer using cmd

      The computer will shut down immediately after hitting this command.

    Shutdown computer using a batch file

    Here are the steps to shut down a computer using a batch file.

    • Open a notepad and click on new file
    • Paste the shutdown code stated above and save the file as turn_off.bat

      shutdown computer using batch file

    • Once you have saved the file, click on the .bat file and your computer will start shutting down.

    Alternately the following code can be used for immediate shutdown.

    SHUTDOWN /p

    How to shutdown the computer by setting time using cmd/batch?

    The code we stated above is used to shut down the computer immediately after hitting the code. We have to use the following command to set the timing for shutting down.

    For example, the following code is used to shut down a computer in 60 seconds.

    SHUTDOWN /s /t 60 /c

    How to log off a computer using batch/cmd?


    Logging off means signing out of from the current logged in account. Here is the code to log off or sign out.

    SHUTDOWN /l

    where l signifies shortcut command for logging off.

    How to hibernate a computer using batch/cmd?


    Hibernating is same as shutting down but when you hibernate your computer, it stores and remembers the previous state of the computer before hibernating and it will resume from there.

    Here is the code to hibernate a computer.

    SHUTDOWN /h

     [adsense1]

    How to reboot a computer using batch/cmd?


    Here is the code required to reboot a computer, be it from command prompt or batch file.

    Here is the code to reboot a computer.

    SHUTDOWN -r -t 10

    This is the code to reboot the computer in 10 seconds.

    Batch file program to shutdown, reboot, hibernate, and logoff the computer

    Let’s take an example where the user will be asked to enter an option whether to logoff or reboot or hibernate or to shutdown the computer.

    Here is the source code.

    @echo OFF
    
    ECHO "Choose an option .."
    ECHO "1 = Logoff"
    ECHO "2 = Reboot"
    ECHO "3 = Hibernate"
    ECHO "4 = Shutdown"
    
    SET /p option=Choose one option-
    
    IF %option%==1 SHUTDOWN /l
    IF %option%==2 SHUTDOWN -r -t 10
    IF %option%==3 SHUTDOWN /h
    IF %option%==4 SHUTDOWN /s /f /t 0
    
    PAUSE

    Save this as .bat file and double click on it to run. The output console will be like the following.

    batch file program to shutdown

    Now depending on the option you choose the computer will be either shut down, logoff, hibernate or reboot.

    Если нужно настроить регулярную (по определенному расписанию) перезагрузку или выключение Windows компьютера (сервера), проще всего создать задание в планировщике задач.

    Содержание:

    • Задание планировщика для автоматической перезагрузки (выключения) Windows
    • Перезагрузка (выключение) Windows компьютеров с помощью групповых политик

    Чтобы разово перезагрузить компьютер в определенное время, можно создать задание отложенной перезагрузки с помощью PowerShell скрипта:

    [datetime]$RestartTime = '17:00'
    [datetime]$CurrentTime = Get-Date
    [int]$WaitSeconds = ( $RestartTime - $CurrentTime ).TotalSeconds
    shutdown -r -t $WaitSeconds

    Команда перезагрузки компьютера в определенное время

    Но чаще всего используются запланированные задания перезагрузки. Например, вам нужно создать задание, которое будет автоматически перезагружать сервер каждый понедельник в 04:00 утра.

    Задание планировщика для автоматической перезагрузки (выключения) Windows

    Откройте консоль Task Scheduler (
    taskschd.msc
    ) и запустите мастер создания задания: Action -> Create Basic Task.

    Задайте имя задания: RebootMonday

    Настройие расписание запуска задания. В нашем примере это еженедельное задание (Weekly), которое запускается каждый понедельник.

    Расписание запуска

    Выберите Start a program. Будем запускать встроенную команду shutdown.exe для перезагрузки с параметрами:

    Program:
    %SYSTEMROOT%\System32\shutdown.exe

    Add arguments (optional):
    /r /f /t 120 /d p:0:0 /c "Автоперезагрузка по понедельникам. Для отмены: shutdown.exe /a"

    Команда перезагрузки shutdown.exe компьютера в планировщике

    • /r
      — перезагрузка
    • /f
      – принудительно завершить все приложения
    • /t 120
      – таймаут перед перезагрузкой
    • /d p:0:0
      — добавить в Event Viewer плановую причину перезагрузки: Other (planned)

    • – вывести информационное сообщение пользователям компьютера перед перезарузкой

    Чтобы задание запускалось автоматически, независимо от наличия активной сессий пользователя на компьютере:

    1. Откройте свойства задания в консоли Task Scheduler
    2. Выберите опцию Run whether user is logged or not
    3. Нажмите кнопку Change User or Group и укажите System
      запуск задания планировщика от имени SYSTEM

    4. Теперь задание будет запускаться от имени NT AUTHORITY\SYSTEM.
    5. Проверьте, что задание включено.

    Теперь данный компьютер будет автоматически перезагружаться в запланированное время, выводя уведомление перед рестартом.

    Предупреждение перед автоматической перезагрузкой Windows

    С помощью PowerShell можно быстро создать такое задание планировщика с командой перезагрузки:

    $taskName = "WeeklyAutoReboot"
    $taskDescription = "Automatically reboots the server every Monday at 04:00 AM"
    $action = New-ScheduledTaskAction -Execute "shutdown.exe" -Argument "/r /f /t 120 /d p:0:0 /c `"Автоперезагрузка по понедельникам. Для отмены: shutdown.exe /a`""
    $trigger = New-ScheduledTaskTrigger -Weekly -DaysOfWeek Monday -At 4:00am
    $principal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -RunLevel Highest
    Register-ScheduledTask -TaskName $taskName -Action $action -Trigger $trigger -Principal $principal

    Перезагрузка (выключение) Windows компьютеров с помощью групповых политик

    Если нужно настроить выключение (перезагрузку) по расписанию нескольких компьютеров в домене AD, такое задание планировщика можно создать с помощью групповых политик.

    1. Откройте консоль управления доменными GPO (
      gpmc.msc
      ), создайте новую GPO и назначьте ее на OU с компьютерами, которые нужно перезагружать/выключать по расписанию.
    2. Отредактируйте новую GPO и перейдите в раздел Computer Configuration -> Preferences -> Control Panel Settings -> Scheduled Tasks;
    3. Создайте новое задание: New -> Scheduled task (At least Windows 7);
    4. Задайте имя задания и запуск от имени SYSTEM (как описано выше)
      Создать задание планировщика в GPO

    5. На вкладке Triggers добавьте расписание для задания
      расписание запуска задания

    6. На вкладке Actions добавьте запуск команды shutdown.exe с параметрами
      команда отложенной перезагрузки

    7. Сохраните задание
    8. Обновите настройки GPO на клиенте, и проверьте что в планировщике задания появилось задание запланированной перезагрузки Windows.
      Задание перезагрузки через GPO создана на клиенте

    Если нужно привязать задание автоматической перезагрузки/выключения компьютера к завершению другого задания (например, перезагрузиться после успешного окончания бэкапа), см. пример реализации в статье Как запустить задание планировщика Windows после завершения другого задания?

    W10
    RUNDLL32 powrprof.dll, SetSuspendState Sleep
    Sleep
     

    W7
    SHUTDOWN /s /t 60 /c «Shutdown in progress, leave the vicinity immediately»
    Shutdown in 60 seconds, with warning message
    Use -m \\remote_computer to shutdown/logoff a remote computer.

    W7
    SHUTDOWN /p
    Immediate shutdown without warning

    W7
    SHUTDOWN /l
    Logoff

    W7
    SHUTDOWN /h
    Hibernate (or sleep if hibernate is disabled)

    XP Pro
    NLTEST /server:localhost /shutdown:»Shutting down, just for fun» 60
    Shutdown in 1 minute, displaying the «reason» in a popup
    Use a remote server name instead of localhost to shutdown that remote server.

    XP Pro
    NLTEST /server:localhost /shutdown_abort
    Abort the shutdown in progress
    Use a remote server name instead of localhost to abort a shutdown in progress on that remote server.

    XP Pro
    WMIC OS Where Primary=TRUE Call Shutdown
    Immediate shutdown
    Use WMIC’s /NODE switch to shutdown a remote computer.

    XP Pro
    WMIC OS Where Primary=TRUE Call Reboot
    Immediate reboot
    Use WMIC’s /NODE switch to reboot a remote computer.

    XP Pro
    WMIC OS Where Primary=TRUE Call Win32Shutdown 4
    Forced logoff (0+4)
    n can be any of the following numbers:

    0	Logoff
    1	Shutdown
    2	Reboot
    +4	Force
    8	Poweroff

    XP Pro
    WMIC OS Where Primary=TRUE Call Win32Shutdown 12
    Forced poweroff (8+4)

    XP
    SHUTDOWN -r -t 10
    Delayed reboot
    Reboot after a 10 seconds delay.
    Can be stopped during those 10 seconds using SHUTDOWN -a

    XP
    SHUTDOWN -s -t 01
    Delayed shutdown
    Shutdown after a 1 second delay, NO poweroff.

    XP
    SHUTDOWN -i
    Interactive use with GUI
    Can be used to shutdown multiple computers.

    TS
    LOGOFF 16 /SERVER:termserv1
    Logoff
    Logoff session 16 on Terminal Server TERMSERV1.
    Use the QUERY USER command to find out which session ID belongs to whom.
    Find more Terminal Server commands.

    TS
    TSSHUTDN 45 /SERVER:termserv1 /POWERDOWN /DELAY:20 /V
    Delayed poweroff
    Notify all users on Terminal Server TERMSERV1, logoff all Terminal Server sessions after 45 seconds, wait another 20 seconds, and then shut down Terminal Server TERMSERV1 and power off.
    See my Terminal Server Commands page for the exact syntax.

    W2K (5)
    DEVCON Reboot
    Reboot
    Requires Microsoft’s DEVCON utility

    W2K
    RUNDLL32 PowrProf.dll, SetSuspendState
    Activate suspend state
     

    W2K
    RUNDLL32 USER32.DLL,LockWorkStation
    Lock
    Credits: Steven Clements (posted on alt.msdos.batch.nt)

    NT+ (1)
    PSSHUTDOWN -d -t 0
    Suspend
    Uses PSSHUTDOWN.EXE from SysInternals’ PS Tools.

    NT+ (1)
    PSSHUTDOWN \\mynt4srv -K -F -T 20
    Delayed poweroff
    Poweroff \\mynt4srv after a 20 seconds delay.
    Can be aborted using PSSHUTDOWN \\mynt4srv -A
    Uses PSSHUTDOWN.EXE from SysInternals’ PS Tools.

    NT+ (1)
    PSSHUTDOWN \\myw2ksrv -O -F -T 0
    Logoff
    Immediately logoff console user on \\myw2ksrv
    Uses PSSHUTDOWN.EXE from SysInternals’ PS Tools

    NT4+RK
    W2K+RK
    SHUTDOWN /L /R /T:0 /Y
    Reboot
    Immediate shutdown & reboot

    NT4+RK
    W2K+RK
    SHUTDOWN /L /T:10 /Y /C
    Delayed shutdown
    Shutdown in 10 seconds, close without saving.
    Can be stopped during those 10 seconds using SHUTDOWN /A

    NT4
    See Reboot NT on my Solutions found in alt.msdos.batch page
    Reboot
    Reboot immediately

    NT4
    RUNDLL32 USER32.DLL,ExitWindowsEx
    RUNDLL32 USER32.DLL,ExitWindowsEx
    Logoff
    Most systems require the command to be called twice before logging off

    Win98/ME
    RUNDLL32 SHELL32.DLL,SHExitWindowsEx n
    Any
    n can be any of the following numbers: (4):

    0	Logoff
    1	Shutdown
    2	Reboot
    +4	Force
    8	Poweroff (if supported by the hardware)

    Win98/ME
    RUNONCE.EXE -q
    Reboot (4)
     

    Win98
    RUNDLL32 KRNL386.EXE,exitkernel
    Poweroff
    Poweroff for ATX boards only, otherwise normal shutdown (3)

    Win9*
    RUNDLL USER.EXE,ExitWindows
    Shutdown (2)
     

    Win9*
    RUNDLL USER.EXE,ExitWindowsExec
    See Remarks
    Win95: various results, usualy fast shutdown (and lock PC), sometimes restart Windows, sometimes reboot.
    Win98: Restart Windows, sometimes reboot.

    Win9*
    RUNDLL SHELL.DLL,RestartDialog
    Restart dialog
    «System Settings Changed, Do you want to restart your computer now?» dialog

    Win31*
    ECHO G=FFFF:0000| DEBUG
    Task Manager popup
    And sometimes reboot

    DOS
    ECHO G=FFFF:0000| DEBUG
    Reboot
    Warm boot, sometimes cold boot.
    May not work with «exotic» memory managers, like Quarterdeck’s QEMM or DesqView; in that case, use RESET.COM instead.

    PowerShell
    Restart-Computer -Force
    Reboot
    Immediately reboot the local computer.

    PowerShell
    Restart-Computer -ComputerName «remotepc» -Confirm -Force
    Reboot
    Reboot remote computer «remotepc», prompt for confirmation on local computer first.

    PowerShell
    Stop-Computer -Force
    Shutdown
    Immediately shutdown the local computer.

    PowerShell
    Stop-Computer -ComputerName «remotepc» -Confirm -Force
    Shutdown
    Shutdown remote computer «remotepc», prompt for confirmation on local computer first.

    PowerShell
    Stop-Process -ProcessName *
    Blue Screen
    Kills all running processes immediately without confirmation, resulting in a «Blue Screen Of Death».

    KiXtart
    $RC = SHUTDOWN( «\\server«, «Shutting down…», 10, 1, 0 )
    Delayed shutdown
    Shutdown \\server in 10 seconds, with message, close without saving, no reboot

    KiXtart
    $RC = SHUTDOWN( «\\server«, «», 0, 1, 1 )
    Reboot
    Immediately shutdown & reboot \\server, without a message

    KiXtart
    $RC = LOGOFF( 1 )
    Logoff
    Forcing applications to close.
    Use 0 instead of 1 if you don’t want to force applications to close

    KiXtart
    $RC = SetSystemState( 0 )
    Lock
    Requires KiXtart 4.51 or later

    KiXtart
    $RC = SetSystemState( 1 )
    Standby
    Requires KiXtart 4.51 or later

    KiXtart
    $RC = SetSystemState( 2 )
    Hibernate
    Requires KiXtart 4.51 or later.

    KiXtart
    $RC = SetSystemState( 3, 0 )
    Poweroff
    Power off with prompt to close applications.
    Use SetSystemState( 3, 1 ) to close applications without prompting.
    Requires KiXtart 4.51 or later

    Perl
    InitiateSystemShutdown( $sComputer, $sMessage, $uTimeoutSecs, $bForce, $bReboot )
     
    General syntax (ActivePerl for Windows only)

    Perl
    InitiateSystemShutdown( «», «», 0, 1, 1 )
    Reboot
    Immediately reboot without message, force applications to close without saving data

    Perl
    InitiateSystemShutdown( «», «Going down…», 10, 0, 1 )
    Delayed reboot
    Reboot after 10 seconds, with message and without forcing applications to close

    Perl
    InitiateSystemShutdown( «10.0.1.16», «Sorry», 5, 1, 0 )
    Delayed shutdown
    Shutdown of remote computer after 5 seconds, with message and forced closing of applications

    Regina Rexx
    RC = W32SysShutdown( how [,force] )
     
    General syntax (Regina Rexx for Windows with W32Funcs only).
    how can be either Reboot, Logoff, Poweroff or Shutdown.
    force can be either Force or Noforce.

    Regina Rexx
    RC = W32SysShutdown( «P», «F» )
    Poweroff
    Immediately shutdown and poweroff, forced closing of application

    Regina Rexx
    RC = W32SysShutdown( «L», «N» )
    Logoff
    Logoff, prompt for saving unsaved data

    WSH
    [1] Set OpSysSet = GetObject(«winmgmts:{(Shutdown)}//./root/cimv2»).ExecQuery(«select * from Win32_OperatingSystem where Primary=true»)
    [2]
    [3]
    for each OpSys in OpSysSet
    [4]     OpSys.Reboot( )
    [5]
    next
    Reboot
    Requires WMI.
    Remove [line numbers].
    (by Alex K. Angelopoulos)

    WSH
    Replace line 4 in the script above with this one:
    [4]    OpSys.Shutdown( )
    to shut down the PC instead of rebooting it.
    Shutdown
    But no poweroff.

     
    See my WSH page for examples on how to reboot or shut down remote computers too.

    WSH
    [1] Const EWX_LOGOFF   = 0
    [2]
    [3]
    Set wmi = GetObject(«winmgmts:{(Shutdown)}»)
    [4] Set objSet = wmi.InstancesOf(«Win32_OperatingSystem»)
    [5]
    [6]
    For Each obj in objSet
    [7]     Set os = obj
    [8]     Exit For
    [9] Next
    [10]
    [11]
    os.Win32Shutdown EWX_LOGOFF
    Logoff
    Requires WMI.
    Remove [line numbers].
    (Posted by Michael Harris on microsoft.public.scripting.vbscript)

     
    My Logoff.vbs combines this code with that of the reboot and shutdown commands, and allows logoff of remote computers as well.

    WSH
    Set objShell = CreateObject( «Shell.Application» )
    Shell.ShutdownWindows
    Open the Shutdown dialog
    Based on the Advanced Stuff listing on groups.msn.com/windowsscript/.

    OS/2
    START /PM SHUTDOWN && EXIT
    Shutdown
    Will still stop and ask for confirmation if a non-PM application is active

    OS/2
    SETBOOT /B
    Reboot
    Unconditional shutdown & reboot from default Boot Manager entry.
    (Mailed by Rick Curry)

    OS/2
    SETBOOT /IBD:C:
    Reboot
    Unconditional shutdown & reboot from C: drive

    OS/2
    SETBOOT /IBA:nonsense
    Shutdown
    Unconditional shutdown & failing reboot.
    Needs Boot Manager installed.
    Will reboot, no questions asked, and then stop if nonsense is an invalid Boot Manager menu entry (which, in this case, is exactly what we want).

    OS/2
    LOGOFF
    Logoff
    Both LAN Server client and Peer

    Понравилась статья? Поделить с друзьями:
    0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии
  • Как пользоваться word бесплатно на windows 11
  • Unsupported windows version detected
  • Windows forms textbox размер шрифта
  • Нас не удалось установить windows в выбранное расположение 0x80300024
  • Как включить игровой режим на windows 10 pro