CamTron Posted February 24, 2016 Posted February 24, 2016 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.
jaclaz Posted February 24, 2016 Posted February 24, 2016 If it's OK to use a third party tool either PowerOff:http://users.telenet.be/jbosman/applications.htmlor Nircmd:http://www.nirsoft.net/utils/nircmd.htmlshould do. jaclaz
Commodore Posted February 24, 2016 Posted February 24, 2016 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".
jumper Posted February 26, 2016 Posted February 26, 2016 Rundll32.exe Kernel32.dll,SetSystemPowerStateThis 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.
CamTron Posted February 27, 2016 Author Posted February 27, 2016 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;} 1
jumper Posted February 27, 2016 Posted February 27, 2016 (edited) 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 February 27, 2016 by jumper
Drugwash Posted February 28, 2016 Posted February 28, 2016 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.
PROBLEMCHYLD Posted February 28, 2016 Posted February 28, 2016 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?
Drugwash Posted February 28, 2016 Posted February 28, 2016 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.
jumper Posted February 29, 2016 Posted February 29, 2016 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.
loblo Posted February 29, 2016 Posted February 29, 2016 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.
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now