Windows – How to run a task every time computer resumes from suspend or hibernate in Windows

hibernatesuspendtask schedulerwindows xp

Is there a way in Windows XP to run a task every time a computer resumes from suspend/hibernate?
On workstation unlock would also work.

Best Answer

There is a partial solution working under WinXP. It requires you to create suspend/hibernation script and always hibernate the comp this way instead of pushing laptop button / through Windows menu.

  1. Download psshutdown: it is in packages of PsTools or SysInternals Suite
  2. Create .bat files as follows, and put them on desktop (or better put them somewhere else and create shortcuts on desktop / quick launch):

suspend.bat:

psshutdown.exe -d -t 00
chkdsk

hibernate.bat:

psshutdown.exe -h -t 00
chkdsk

That way, chkdsk will be invoked just after you return from suspend/hibernate (notice however, if you have to provide password to unlock after standby/hibernation, chkdsk will start in background before you unlock Windows).

Of course, you have to provide full path to psshutdown.exe, or add the folder where you unpack it to PATH (or, unpack to %WINDIR% or other folder like that).

NOTE: You can disable power button / sleep button in Control Panel > Power Options: Set to 'Do nothing' .

enter image description here

However I don't know if you can disable standby from Windows menu.

A dirty hack to disable hibernation from Start > Turn Off Computer is to change hibernate.bat to:

powercfg.exe /hibernate on
psshutdown.exe -h -t 00
powercfg.exe /hibernate off

so you enable hibernation from command line, hibernate, and immediately disable it after you come back from hibernation.

Related Question