Windows command sleep command

Команда SLEEP — задать период ожидания.

Команда SLEEP входит в состав дополнительного пакета Resource Kit и используется в командных файлах для организации режима ожидания фиксированного интервала времени.

Формат командной строки:

sleep -m миллисекунды

SLEEP /? — отобразить краткую справку по использованию команды

sleep 10 установить режим ожидания 10 секунд.

sleep –m 2500 — установить интервал ожидания 2500 миллисекунд (2.5 секунды).

Для прерывания команды sleep можно использовать комбинации клавиш CTRL+C или CTRL+Break.

В качестве альтернативы команды sleep используется команда ping для петлевого интерфейса с указанием количества эхо-запросов, соответствующего длительности задержки в секундах. Поскольку эхо-запрос для петлевого интерфейса выполняется практически мгновенно, а интервал между запросами равен 1 секунде, такой способ вполне приемлем, и не требует установки Resource Kit или копирования утилиты sleep.exe для выполнения задержки на требуемый интервал времени.

Примеры выполнения задержек с использованием ping.exe :

ping –n 1 localhost > nul — задержка на 1 секунду. Перенаправление вывода на фиктивное устройство nul используется для подавления вывода утилиты ping.exe

ping –n 1 127.0.0.1 > nul — то же, но с указанием IP-адреса петлевого интерфейса.

В операционных системах Windows Vista и старше, для организации задержек при выполнении командных файлов можно использовать команду TIMEOUT

Как перевести компьютер в режим сна из командной строки / меню «Выполнить»?

Я знаю, что почти все в Windows, например, открытие любого приложения, можно выполнить из командной строки или из меню « Выполнить» .

Как я могу перевести компьютер в режим сна или выключить его ? Какая команда для этого?

Вы найдете, shutdown.exe чтобы быть вашим другом.

Другие удобные команды смотрите в этом посте:

Блокировка рабочей станции

Кажется, что спать на компьютере проблематично, если включен режим гибернации.

Копирование из других ответов:

Вы можете попробовать PsShutdown или:

Команда rundll32.exe powrprof.dll, SetSuspendState 0,1,0 для спящего режима верна — однако она будет переходить в спящий режим вместо спящего, если вы не отключите спящий режим.

Вот как это сделать:

Перейдите в меню «Пуск» и откройте командную строку с повышенными правами, введя cmd.exe, щелкнув правой кнопкой мыши и выбрав «Запуск от имени администратора». Введите следующую команду:

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

Одним из инструментов Sysinternals Microsoft является PsShutdown с помощью команды psshutdown -d -t 0 он будет правильно спать, не спящий режим , компьютер

rundll32.exe powrprof.dll,SetSuspendState 0,1,0 Правильная команда для сна верна — однако она будет переходить в спящий режим вместо сна, если вы не выключите спящий режим.

Читайте также:  Bco system cryptographic plugin mac os big sur

Вот как это сделать:

Перейдите в меню «Пуск» и откройте командную строку с повышенными cmd.exe правами. Для этого введите правой кнопкой мыши и выберите « Запуск от имени администратора» . Введите следующую команду:

NirCmd работает в Windows 8 (я полагаю, что это также работает и в Windows 7) → http://www.nirsoft.net/utils/nircmd.html
Команда есть standby , но она переводит компьютер в спящий режим.

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

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

Я создал ярлык для rundll32.exe powrprof.dll,SetSuspendState 0,1,0 (также пробовал с 0,0,0), но запуск ярлыка, похоже, перевел мой компьютер в спящий режим. Я не мог разбудить ПК с помощью клавиатуры; Пришлось нажимать кнопку включения, и на ПК показывались сообщения системной платы и т. Д.

Прочитав документ Windows API , я создал очень простую программу, набрав всего 3 строки. Я загрузил исполняемый файл, скомпилированный на эту страницу (нажмите «SleepTest.exe») , но через некоторое время этот файл может быть удален (это бесплатный сайт для размещения файлов, который я только что нашел при быстром поиске в Google).

Если вы не доверяете мне (что вполне нормально) или файл был удален, вы, конечно, можете скомпилировать код самостоятельно. Вам необходимо добавить «PowrProf.lib» к дополнительным зависимостям компоновщика.

rundll32.exe powrprof.dll,SetSuspendState 0,1,0 кажется, делает то же самое, но каким-то образом вышеприведенная программа не переводит компьютер в спящий режим. Я мог мгновенно разбудить компьютер (без сообщений на материнской плате и т. Д.), Нажав любую клавишу на клавиатуре.

Вы можете запустить параметры приостановки или спящего режима из командной строки, как указано ниже и упоминается в этой статье .

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

Сначала необходимо отключить Hibernate в Windows, а затем перевести компьютер в состояние сна . Используйте следующие две команды:

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

Вот статья об использовании CLI для выключения.

Microsoft предоставляет PsTools, который дает вам отключение CLI вместе с другими полезными инструментами. Вы можете получить это здесь .

у меня работает только QUICK SLEEPER (работает в Windows 7,8,10).

Sleep/Timeout command in Windows 7

There are two commands which we can use to make a batch command sleep for some time. The native available ‘timeout’ command and the resource kit tool ‘sleep’.

Timeout command

We can use ‘timeout’ command in Windows 7 to pause execution for some time and then continue. We can specify the number of seconds to wait, it would wait till the time elapses or until user presses any key.

Example: To wait for 10 seconds

Example: To sleep for 2 minutes and ignore any key presses

Sleep command

Windows provides a resource kit tool ‘sleep’ which can be used in batch files or command prompt to pause the execution and wait for some time. Though the tool was intended for XP, I have used it on Windows 7 and it works perfectly fine. Find the download location and installation instructions here :Download Windows resource kit tools .

Читайте также:  Avermedia studio 507 linux

Syntax of sleep command:

Examples:
If you want to pause the execution of a batch file for 50 seconds, then you should insert below statement in your batch file.

If you want to wait for 100 milli seconds, then you can run the below command.

Sleep command should also work find on Server 2008 and Server 2008 R2.

Instead of downloading extra tools, you can stick with the ping command as well:
ping /t 50 localhost
will “sleep” 50 secs before going on

Out of curiosity, I compared ping vs timeout and both seem to have stopped exactly at the same time. However, with the availability of timeout command, we don’t have to look for such alternatives.

Excuse my typo. For 50 sec sleep, use

ping localhost -n 50

in Windows Vista an later, you can use Timeout /t

How to sleep Windows 10 from the command line

Recently one of our readers asked us how to make his Windows 10 PC enter sleep from the command line. This can be definitely useful if you are using the sleep mode frequently and want to create a shortcut to put your PC into sleep directly or via some batch file. In this article, I would like to share a working way to initiate sleep from the command line.

Windows10 only allows the hardware Power button or the Start Menu power button to enter Sleep (standby) mode. It does not provide a command line tool to directly enter sleep.

How to sleep Windows 10 from the command line

If hibernation is disabled on your PC, you can enter Sleep mode using the following command:

But if you have enabled hibernation, then the above command hibernates the PC instead of entering sleep mode. So you need to apply a workaround which isn’t exactly ideal, something like this.

In the example above, I’ve used the powercfg command to disable hibernation, just before using the Rundll32 command. Then the rundll32 command will work correctly and put the PC into sleep. When it wakes up, the last line will turn on hibernation. Another issue with this workaround is that it must be executed from an elevated command prompt.

Instead, I will show you how to enter sleep without disabling hibernation and without requiring elevated (administrator) privileges.

Download the PsShutdown tool by SysInternals. Using this tool, you will be able to make the PC enter sleep mode directly by giving a single command:

I recommend PsShutdown as the preferred way to send a PC to sleep.

Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:

Share this post

Читайте также:  Windows 10 не реагирует микрофон

About Sergey Tkachenko

Sergey Tkachenko is a software developer from Russia who started Winaero back in 2011. On this blog, Sergey is writing about everything connected to Microsoft, Windows and popular software. Follow him on Telegram, Twitter, and YouTube.

4 thoughts on “ How to sleep Windows 10 from the command line ”

The 0,1,0 parameters don’t work because SetSuspendState was never designed to be invoked by rundll32! All recent version of Windows have a forgiving rundll32 implementation that allows you to corrupt the stack but you are still passing random parameters to the function you are calling. See https://blogs.msdn.microsoft.com/oldnewthing/20040115-00/?p=41043

Brilliant tip, I’ve always uses the elevated command prompt way and disabled Hibernation to sleep, using your tip is very useful, thanks for sharing.

How to sleep a Windows computer from the command line

Recently one of our readers asked us how to make his Windows PC enter sleep from the command line. This can be definitely useful if you are using the sleep mode frequently and want to create a shortcut to put your PC into sleep directly or via some batch file. In this article, I would like to share a working way to initiate sleep from the command line.

Windows only allows the hardware Power button or the Start Menu/Start screen power button to enter Sleep (standby) mode. It does not provide a command line tool to directly enter sleep.

If hibernation is disabled on your PC, you can enter Sleep mode using the following command:

But if you have enabled hibernation, then the above command hibernates the PC instead of entering sleep mode. So you need to apply a workaround which isn’t exactly ideal, something like this.

In the example above, I’ve used the powercfg command to disable hibernation, just before using the Rundll32 command. Then the rundll32 command will work correctly and put the PC into sleep. When it wakes up, the last line will turn on hibernation. Another issue with this workaround is that it must be executed from an elevated command prompt.

Instead, I will show you how to enter sleep without disabling hibernation and without requiring elevated (administrator) privileges.

Download the PsShutdown tool by SysInternals. Using this tool, you will be able to make the PC enter sleep mode directly by giving a single command:

I recommend PsShutdown as the preferred way to send a PC to sleep.

Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:

Share this post

About Sergey Tkachenko

Sergey Tkachenko is a software developer from Russia who started Winaero back in 2011. On this blog, Sergey is writing about everything connected to Microsoft, Windows and popular software. Follow him on Telegram, Twitter, and YouTube.

2 thoughts on “ How to sleep a Windows computer from the command line ”

How to do this remotely to a computer in my home group?

Оцените статью