#1  
Old 12-25-2009, 12:09 AM
fixup fixup is offline
Technophile
 
Join Date: Dec 2008
Location: USA, Northwest
Posts: 496
Default A useful utility - run a program before standby

In the past I've seen many problems caused by standby (suspend, sleep). The cause is some software and hardware drivers don't handle standby event properly. Therefore some of these problems can be fixed by running a program before standby.

For example, newer printer servers for multiple function printers use remote USB bus. This driver hangs almost all my computers when going into standby mode.

So I made a program, OS_Events, to wait for standby event and run a program of my choice right before standby. When a computer is going to sleep, this program will call "OnStandby".

To use it, make a batch or script file and name it as "OnStandby.bat" or "OnStandby.vbs". Or simply rename your exe file to OnStandby.exe. In this script you can do anything you need. In my case, it has this line:

devcon restart root\BusRmUsb

which resets the remote USB bus.

Then load OS_Events.exe. When the computer is about to go to sleep, OS_Events will receive the message and call OnStandby script. This script then resets the remote USB bus, making it ready for the coming sleep request.

If you also need to run a program after waking up, you simply make another batch file and name it as "OnWakeup.bat". If you want to run this script even when you are not present (i.e. you did not press the power button, but the computer turns on by itself as scheduled, for timed hibernation or for whatever reason), then add an "A" to the file name (i.e. OnWakeUpA.bat). Don't let both present.

I think this is a very handy utility, but I've never seen such a thing so I had to make one. It is extremely small and efficient, won't cause any side effect, meanwhile still very flexible. It does not have a window to bother you, just does its job for you under the background. If you need to exit it, you can use task manager to kill it.

[update]xStandbyHandler is the service version. To install the service, run "xStandbyHandler.exe -i"; or "-u" to uninstall. As this is running in service mode, some programs won't run properly, such as, unfortunately, devcon (especially when the driver is unsigned).
Attached Files
File Type: zip OS_Events.zip (39.0 KB, 352 views)
File Type: zip xStandbyHandler.zip (29.4 KB, 248 views)

Last edited by fixup; 12-27-2009 at 12:28 AM.
Reply With Quote
  #2  
Old 03-01-2010, 11:21 AM
hatsekidee hatsekidee is offline
Tech Curious
 
Join Date: Mar 2010
Posts: 1
Default Re: A useful utility - run a program before standby

Perfect! But does it work on W7?
It seems that OnWakeup.bat is activated but OnStandby.bat is not!
I places the 3 files onder c:\ root (incl OS_events.exe)

I start the OS_Events.exe executable

I will use it to end the applesyncnotifier.exe which consumes 60% of my CPU when system awakes form the sleepmode!

Please help me!

KR Arni
Reply With Quote
  #3  
Old 04-16-2010, 05:18 AM
chuzie chuzie is offline
Tech Curious
 
Join Date: Apr 2010
Posts: 1
Default Re: A useful utility - run a program before standby

Ive been having issues with my external hard drives becoming corrupt due to the computer going to standby without the drives being safely removed. Although I have them optimized for quick removal and disk caching is disabled I still frequently find my drives corrupted. Your program works just fine but I do have an issue.

I created OnStandby.bat with

tskill explorer
devcon remove usb\vid_059*
devcon remove USB\VID_0D49*

Devcon will not remove the drive unless all open windows associated with that drive are first closed (that applies to both remove and disable commands). I was reluctant to use tskill to close explorer because of the perceived need to restart explorer to gain a taskbar on wake and the time that would take. I gave it a shot and upon wake, the taskbar is intact and both drives are recognized automatically.

The only issue I am having is that one of my drives will not remove when the bat file is executed during standby. When I run the bat file from the command prompt everything works just fine. I don't understand why this happens only during the standby process.

Thanks!

Last edited by chuzie; 04-16-2010 at 07:14 AM.
Reply With Quote
  #4  
Old 04-27-2011, 02:55 AM
johnye_pt johnye_pt is offline
Tech Curious
 
Join Date: Apr 2011
Posts: 1
Thumbs up Re: A useful utility - run a program before standby

Many thanks for your useful utility!

My new wireless card drivers (TP-Link TL-WN861N v2) are not compatible with standby/resume, so i could not use standby because when resuming, the computer would always freeze.

Placing xStandbyHandler.exe, OnStandby.bat (devcon disable PCI\VEN_168C^&DEV_0029) and OnWakeup.bat (devcon enable PCI\VEN_168C^&DEV_0029) in Windows\System32 solved my problem! And yes, your service works fine with devcon.exe and Windows XP Home! (i "borrowed" devcon.exe from Windows XP Pro )
Reply With Quote
  #5  
Old 11-17-2011, 01:39 PM
Paisley Pirate Paisley Pirate is offline
Tech Curious
 
Join Date: Nov 2011
Location: Derby (Wichita), KS
Posts: 2
Default Re: A useful utility - run a program before standby

I would like to thank both fixup for making this utility, and johnye-pt for trailblazing my exact problem!

I was also having the not waking from sleep with my TP-Link wireless card... and I can verify that it does indeed work with XP-Tablet / SP3 and xStandbyHandler. It goes to sleep and it comes back on (instead of hanging).

Now to figure out what the calls are for my DeLorme GPS serial emulator, and add it in, too.. (it doesn't cause it to hang, it just goes away on sleep...)

Thank YOU BOTH!
Reply With Quote
  #6  
Old 02-06-2012, 02:02 AM
banjomoomintoog banjomoomintoog is offline
Tech Curious
 
Join Date: Feb 2012
Posts: 1
Default Re: A useful utility - run a program before standby

Great - thanks. Disables my TP-LINK wireless card and deals with file encryption (truecrypt) at the same time.
Reply With Quote
  #7  
Old 04-10-2012, 04:21 AM
owl11 owl11 is offline
Tech Curious
 
Join Date: Apr 2012
Posts: 2
Default Re: A useful utility - run a program before standby

I join the TP-Link victims who resolved their problems thanks to OS_Events by fixup.
Reply With Quote
  #8  
Old 04-11-2012, 03:35 AM
owl11 owl11 is offline
Tech Curious
 
Join Date: Apr 2012
Posts: 2
Default Solution to wakeup problems with WN861N etc

To all owners of TP-Link WIFi cards (eg WN861N) suffering from hangups after standby/hybernate.

The OS_events is a nice tweak, but the real solution is to install the latest version of the driver for Atheros 5008-based cards, for example

atheros_wifi_9.2.0.470-allos

- a universal (all Windows) driver pack, available, for example, from station-drivers dot com.

Alternatively, look up for the versions 7.7.0.509 and 7.7.0.529, which also seem to cure the problem (which occurs with the "official" 7.7.0.329 from the TP-Link sites for WN861N V2).

Please, note that, most likely, the shortcut keystroke (usually Fn+F2) to turn the radio off/on will not work with the replacement card, because many manufacturers assign it at the OS level for a specific device (it is not a property of the WiFi adapter). In my case, I assigned the F2 key to a shortcut to a little AutoIt-3 script which toggle the device off/on. This solution was offered by rarst dot net/script/devcon/

Good luck to all!

Last edited by owl11; 04-11-2012 at 03:41 AM.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -10. The time now is 10:15 PM.

Powered by vBulletin®
Back to Top Copyright © 2006-2014 CrowdGather. All rights reserved. About Pocketables | Advertisers | Investors | Legal | Contact