Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Is there any way to enter standby mode from a batch file?

Featured Replies

I know that you can use "rundll.exe user.exe,exitwindows" to shut down the computer, "rundll.exe user.exe,exitwindowsexec" to reboot, etc., but I haven't found a way to make the computer enter standby (or sleep mode as it's called in Vista and later) through a batch file. My previous keyboard had a button for this, but since that one died on me, my new keyboard lacks a standby button, and I find it a bit inconvenient to open the start menu, click Shut Down and select Stand by from the drop down menu.


Perhaps i can suggest you this simple "hardware" solution: set the power button of your pc as a standby button.

These are the steps: press right-click on your desktop, then properties -> screen saver -> power -> advanced. Therefore select Standby in "When i press the power button on my computer".

Rundll32.exe Kernel32.dll,SetSystemPowerState
This works in a shortcut to which you can assign a hot key and icon of your choice.

To be fully compatible with Rundll/Rundll32, a 16/32-bit function must have four parameters like WinMain. SetSystemPowerState has only three parameters so after the system comes out of suspend you will see a system error dialog.

WSH scripts can surely be written to simulate pressing the Suspend key, or even to call SetSystemPowerState directly. The code could be written to a temp file by a batch file if you really need batch support. Ask in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.) and someone will probably rise to the challenge.

  • Author

I just wrote this really simple C++ program, assigned a keyboard shortcut to it, and it does the trick!

#include <windows.h>int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){    if(!SetSystemPowerState(TRUE, FALSE))    {        MessageBox(NULL, "Could not enter standby mode.", NULL, MB_ICONERROR | MB_OK);        return 1;    }    return 0;}

And even simpler:

void WinMainCRTStartup (void) {  SetSystemPowerState (!!GetModuleHandle("Suspend.exe\0.................."), TRUE);  ExitProcess (0);}
Suspends to RAM (forced) if named Suspend.exe. To hiberate/suspend-to-disk instead, change the filename.

Extra space reserved for hexing of filename string needed for Suspending to RAM.

Suspend.7z

Edited by jumper

Has anyone tested SetSuspendState() in powrprof.dll?

I have a Win2000 version of the library on my main 98SE system. Unfortunately no guinea pig-machine to test on, at the moment.

 

There are a few other useful APIs such as IsPwrHibernateAllowed(), IsPwrSuspendAllowed(), IsPwrShutdownAllowed() that could report whether a certain state can be induced or not, as well as the more complex GetPwrCapabilities() that returns a structure full of power-related information.

 

I assume IsPwrHibernateAllowed() and IsPwrSuspendAllowed() would eliminate the frustration of not being able to set a certain power state.

Has anyone tested SetSuspendState() in powrprof.dll?

I have a Win2000 version of the library on my main 98SE system. Unfortunately no guinea pig-machine to test on, at the moment.

 

There are a few other useful APIs such as IsPwrHibernateAllowed(), IsPwrSuspendAllowed(), IsPwrShutdownAllowed() that could report whether a certain state can be induced or not, as well as the more complex GetPwrCapabilities() that returns a structure full of power-related information.

 

I assume IsPwrHibernateAllowed() and IsPwrSuspendAllowed() would eliminate the frustration of not being able to set a certain power state.

I could test it, what version is it?

Well this is a very interesting question.

ProductVersion says 5.00.0910.1900 and ProductName says 'Microsoft® Windows ® 2000 Operating System'.

However, the file timestamp is 1999.04.23, which means it's the original file that shipped with 98SE. And indeed, checking with the CD it is the original file.

I now wonder, how come an official 98SE file delivered in '99 appears as belonging to Windows 2000…

 

Anyway, I've already performed some limited tests and all above-mentioned APIs except for SetSuspendState() do work correctly. I haven't tried the latter because I don't like my hard drive to be stopped unnecessarily.

SetSuspendState() doesn't work with Rundll32 in 9x (but reportly does in 2k and up). I tried it. It should work when called with the correct parameters from within a program, however.

Sleep.exe uses SetSuspendState().

 

There is also Sleeper and Wizmo which might be of interest/useful and probably a few more to find all over the interwebz.

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.