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.

migrated from serverfault.com Dec 3 '11 at 16:56

This question came from our site for system and network administrators.

  • 1
    On XP, no. On 6.0+ yes, it's a trigger in the task scheduler. – Chris S Nov 29 '11 at 15:56
  • @Chris S: Is there any other way to do it? – kinokijuf Nov 29 '11 at 16:21
  • To my knowledge, no. Perhaps there is a program around that can help, but I don't know of any. – Chris S Nov 29 '11 at 17:02
  • How do you currently trigger suspend or hibernate itself? – Paul Dec 24 '11 at 4:00
  • Normally, from start menu. – kinokijuf Dec 25 '11 at 7:26

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):


psshutdown.exe -d -t 00


psshutdown.exe -h -t 00

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.

  • 1
    @kinokijuf He was putting in chkdsk as an example. Replace that line with whatever command you need to run – Canadian Luke Dec 28 '11 at 21:53
  • 3
    Why downvote? Okay maybe it's a bit complex, but well, how does your mum run any other program? Isn't it a shortcut in desktop / quick launch / start menu? – jakub.g Dec 28 '11 at 22:06

Hibernate Trigger should do the trick.

From their documentation:

Hibernate Trigger is a small program that will detect whenever the system is put into suspend or hibernation mode. When the system starts going into suspend, Hibernate Trigger will halt the Suspend operation and execute a command of your choice. Also, when the system resumes, hibernate will execute a command of your choice.

  • I don't want to halt the suspend. – kinokijuf Dec 26 '11 at 17:19
  • That's optional. The boldfaced part the important one. – Dennis Dec 26 '11 at 17:29
  • Also, this program doesn't work on a non-English version of Windows. – kinokijuf Dec 26 '11 at 17:29
  • That part, I wouldn't know about. My Windows is in English. – Dennis Dec 26 '11 at 17:36

Lock and Load does what I’m looking for.

Lock and Load is an application that allows you to listen to various windows events, and execute an arbitrary number of commands as a response.


I don't think there is an exact trigger for that, but perhaps there is a workaround.

Assuming your user account is password protected, just use the trigger "On workstation unlock", so the command is run whenever the user logs back in from hibernate/sleep. Although, the down side is that if the user(s) regularly lock whenever they leave the PC on, it will also be run upon unlocking after that.

  • Where do I find that trigger? – kinokijuf Nov 29 '11 at 15:47
  • 1
    I've only been able to check this on a Win7 box. Not entirely sure if XP has that trigger yet. Sorry for the confusion. – Oldskool Nov 29 '11 at 15:57
  • 3
    Vista overhauled the task scheduler completely. Your answer doesn't apply to XP. – kinokijuf Nov 29 '11 at 16:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.