Capture XP wake up event

I have a batch file scheduled to run every ten minutes to scan for new hardware because my internal HD goes missing after the PC sleeps.  I would like to simply have this code run once on wake up.

Is there a way to capture an event when windows xp wakes up from sleep.

Here is the batch file code.  I'm willing to encapsulate it in another language if necessary.


@echo off

IF NOT EXIST N:\NUL (
echo %date% %time% N drive missing, rescanning >> .\log.txt
devcon rescan
)

Open in new window

LVL 7
mmr159Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

JimBeveridgeCommented:
Getting a wakeup notification in a C or C++ application is straightforward. You just handle the WM_POWERBROADCAST message in the main message loop and you'll get the information you need.

http://msdn.microsoft.com/en-us/library/aa373247(v=VS.85).aspx

You can then issue the devcon rescan command using the "system()" function.
mmr159Author Commented:
That looks like it will do it.  I guess there is no way to have windows fire off a the batch code without encasing it in a loop?
JimBeveridgeCommented:
I'm not sure what you are getting at when you say "encasing it in a loop."  Do you mean the message loop? The thread blocks while waiting for messages, so it's not hogging CPU resources.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mmr159Author Commented:
Oh, right.  I'm 99% sure this will work but I have no time time to test it.  So, I haven't abandoned.  Will get to it as soon as I can.
mmr159Author Commented:
I may never get to implementing this now.  This is what I was looking for, however.  Thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows XP

From novice to tech pro — start learning today.