AutoStandByPro
AutoStandByPro
Features Plus Help FAQ Log in Download Free
Run files before an action PLUS
Close a program properly, save a file or stop a service first — then let the computer sleep, hibernate, shut down, restart, log off or lock. With a countdown and a Cancel button, so you stay in control.
What happens, step by step
1. A rule fires
From this moment the files and the action are one action. No other rule does its action, no rule asks for confirmation (a confirmation window that is open closes), and no second action starts. They all wait until it is over.
2. The countdown
For a rule that does not ask for confirmation, a small notice says that your files run first, and counts down: 10 seconds by default, from 0 to 60. Nothing has run yet, so if you click Cancel nothing runs and the action is not done. If you prefer, using the keyboard, the mouse or a game controller cancels it too.
The notice with the countdown and the Cancel button
3. Your files run
One after the other, hidden, in the order of their names (01-, 02-…), for up to the time you choose: 30 seconds, 1, 2, 3 or 5 minutes, or no limit. The notice shows the time left, and Cancel is still there. When they are done, the action goes ahead.
The notice while the files run
4. Cancel, or the time is up
The file that still runs is asked to cancel: a file appears at the path in the variable ASBP_CANCEL_FILE, which a script can look for, and a program with a window is asked to close. It is given a few seconds (5 by default, 0 to 60) to end by itself and undo what it did. Then it is stopped by force, together with the programs it started. If you cancelled, the action is not done and the notice says what happened; if the time was up, the action goes ahead.
The notice after a cancel while the files ran
5. The action
After Sleep or Hibernate the rules wait until the computer wakes up (and for 3 minutes at most, if Windows never went to sleep). After the other actions they wait only until the action has been asked for.
If the computer goes to sleep meanwhile
If the computer goes to sleep while the files run (you put it to sleep yourself, or the lid closed), the whole action is cancelled and the files are stopped. Otherwise it would go to sleep again just as you woke it.
What is stopped, and what is not
Only a file that is still running when it is stopped is stopped, together with the programs it started that are still linked to it. A program that a file started and left running, after the file itself ended, is not stopped: it keeps running through the sleep and after the wake-up. So to keep a program running, let your file start it and end. A file that waits for the program is stopped with it. You can turn the stopping off (Stop unfinished files); stopping a file in the middle can leave its work half done, so write long jobs in small pieces and let them look for the cancel file:
@echo off
set /a step=0
:work
if exist "%ASBP_CANCEL_FILE%" goto cancelled
rem ONE small piece of the work here (a few seconds at most)
ping -n 3 127.0.0.1 >nul
set /a step+=1
if %step% LSS 10 goto work
goto end
:cancelled
rem undo what the earlier pieces did
:end
The settings
All in Settings → Power Events: the folder with your files (or one program or script), the actions it runs for, whether it runs when a rule starts the action or also when you start it from a menu, Wait up to, Start in (the countdown), Do the action even if the computer is used, Stop unfinished files, Wait for a file to cancel, and Do not show the notices. The notice is also shown in Silent Mode, because it tells you that the computer is about to sleep; only that last setting hides it, and then there is no countdown.
The Power Events tab of the Settings
If you want the rules to start counting again when an action did not happen (Windows did not sleep, or the action gave an error), tick If an action does not happen, reset the rules on the Power tab. By default the rules simply go on.
The Power tab of the Settings
Sample files
The first time AutoStandByPro starts, it makes the folder Before Action Files in Documents\AutoStandByPro with a Samples folder inside. The files in Samples are never run: copy one up, next to the Samples folder, and change it.
  • Before-Sleep.bat, Before-Hibernate.bat, Before-Shutdown.bat, Before-Restart.bat, Before-LogOff.bat, Before-Lock.bat: one for each action.
  • Before-AllActions.bat: one file for every action; it looks at the action it is told.
  • Before-LongTask.bat: a job in small pieces that undoes its work and ends by itself when the action is cancelled.
  • Before-KeepProgramRunning.bat: starts a program and ends, so the program keeps running.
  • Before-AllActions.ps1: the same in PowerShell.
Every file is told the action (%1 and ASBP_ACTION), who started it (ASBP_TRIGGER: Rule or Manual), the name of the rule (ASBP_RULE) and the cancel file (ASBP_CANCEL_FILE).
The full description is in the help. Back to Features or the Plus comparison.
© 2026 Phenomenal Solutions — AutoStandByPro
Awards Screenshots Help Purchase Report a Bug Log in ContactTermsPrivacyRefunds