Displaying dialog box via post-command batch file
INTRODUCTION:
I have a differential backup plan established that runs a script using Acronis Backup and Recovery 11’s (ABR11) post-command functionality once the backup completes. I have tested the script itself by launching it manually (double clicking on the file) and it works as intended each and every time I run it. In addition, when I run it from within ABR11 using the “Test Command” button, ABR11 reports that the command executed successfully and indeed I get the intended result (see below). However, when I actually run the plan, the intended result does not occur.
GOAL:
I want the pc to do a delayed shut down after the backup has completed. Furthermore, I want a message to be displayed warning of the impending shutdown and a countdown timer to show the number of seconds until shutdown AND a 'Cancel' button so the user can terminate the shutdown if desired.
With Windows XP, I could simply use the built-in shutdown.exe with its various switches and it would display a small GUI dialog box with a countdown and a “Cancel” button. However, starting with Vista, Microsoft removed displaying the countdown of seconds and the “cancel” button from Shutdown.exe capability, which launched me on a 2-day online search for a replacement solution. I saw a variety of 3rd party apps and chose Poweroff.
ABOUT PROGRAM:
The utility, Poweroff 3.0, (http://users.telenet.be/jbosman/poweroff/poweroff.htm) is a small program that controls various power settings on a pc. It has the option of being run as a service and can be controlled through a GUI or its own command line interface.
INTENDED RESULT:
For Acronis to execute ’Shutdown.cmd’ (formerly .bat) post-command batch file, which, among other things, executes a command line causing Poweroff to initiate a shutdown of the pc, displaying a GUI dialog box (please see attached image) with a message, count down timer showing how many seconds are left until shut down and a ‘cancel’ button to terminate the shutdown if desired.
ISSUE:
ABR11 successfully executes the Poweroff commands and the pc indeed shuts down after 2 minutes as intended, however, the aforementioned Poweroff GUI dialog never appears.
Note: Machine Option is set to “Stop running tasks and shut down” in case machine is about to be shut down while a task is running.
TROUBLESHOOTING STEPS PERFORMED:
1. Tested batch file execution manually. Shutdown.bat successfully achieves intended result (Poweroff dialog box appears); and shuts down Windows successfully.
2. ABR11 'Test Command” button successfully achieves intended result and shuts down Windows .
3. Ran actual backup with post-command set to run Shutdown.bat.
Result: Poweroff GUI dialog didn’t appear when Acronis executed post command. Command did however successfully execute, shutting computer down after 2 minutes as intended.
Once I discovered the Poweroff GUI dialog wasn’t displaying via ABR11, I created a stripped-down batch script to just test the Poweroff commands portion that was not working as intended. The results below are from using that stripped-down version.
4. Set working directory to batch file directory (previously left field empty).
Result: Computer shut down after 2 minutes but Poweroff GUI dialog wasn’t displayed.
5. Google search resulted in an Acronis forums post by Grover suggesting changing .bat to .cmd and making sure file has full control rights for all users.
Found an off-site suggestion to make sure script is launched with admin privileges by creating shortcut to run batch file, setting shortcut to run as admin and setting post-command as path to shortcut.
Result: Trying each of these suggestions separately resulted in the 2 minute delayed shutdown but no Poweroff GUI dialog box appearing.
6. Wondered to myself if it is even possible to launch an external program (*.exe) from Post Command (I noticed one of the listed acceptable files types is .exe). I set Acronis to launch the program directly C:\PowerOff\pwroff30\poweroff.exe with working directory set as C:\PowerOff\pwroff30\.
Ran ‘Test Command’ and it displayed Poweroff program window successfully.
Ran actual backup with this post-command.
Result: Poweroff program window never appeared.
7. Went back to using batch file (.cmd). Installed Poweroff as service. Edited Shutdown.cmd to use service instead of path to Poweroff executable.
Manually ran batch file to test it.
Result: Achieved intended result.
Ran batch file via “Test Command” button in Acronis.
Result: Achieved intended result.
Ran actual backup with above mentioned cmd file as post-command.
Result: Computer shut down after 2 minutes but Poweroff GUI dialog wasn’t displayed.
**I have scoured the log files resulting from these attempts listed above but do not see any error relating to the execution of the batch file. For that matter, I don't see any mention anywhere in the logs of the post command batch file at all. I've attached a log (in Excel format) of the latest attempt I made**
********************************
Shutdown.cmd script:
********************************
ORIGINAL SCRIPT
(ABR11 successfully executes all these commands, closing the various listed programs and shutting down the computer, only it doesn’t display the Poweroff dialog box with countdown timer and cancel button).
@echo off
::Prevents commands from being displayed in dos window
nircmd closeprocess chrome.exe
::Closes Chrome
nircmd win close class "IEFrame"
::Closes Internet Explorer windows
nircmd closeprocess ManagementConsole.exe
::Closes Acronis Backup and Recovery
nircmd win close class "CabinetWClass"
::Closes Windows Explorer windows (if any are open)
poweroff poweroff -notray -warn -warntime 120 -msg "Backup completed...shutting down computer"
::Uses Poweroff to initiate a 120-second delayed shutdown and to display a GUI with notification message, countdown timer and cancel button option (like Windows XP used to do)
exit /b
::Exits batch file
********************************
STRIPPED-DOWN 'TEST' SCRIPT:
@echo off
::Prevents commands from being displayed in dos window
poweroff poweroff -notray -warn -warntime 120 -msg "Backup completed...shutting down computer"
::Uses Poweroff to initiate a 120-second delayed shutdown and to display a GUI with notification message, countdown timer and cancel button option (like Windows XP used to do)********************************
SPECS:
AB&R11 Build 17440 (full version, not trial)
Windows 7 Ultimate SP1 x86
HP Compaq DC7600 SFF
2.8 GHz Pentium D
2.5GB RAM
CONCLUSION:
At this point, I'm not sure what else to try. Although I didn't list it in the troubleshooting section, I even tried to see if ABR11 would launch Microsoft Word with a script, it didn't, the Word window never appeared so it appears to be somehow related to not being able to launch an external GUI with ABR. Any feedback is greatly appreciated.
Thank you.
Anhang | Größe |
---|---|
intendedresult.jpg | 18.23 KB |
log_20150703_417pm.xlsx | 13.38 KB |

- Anmelden, um Kommentare verfassen zu können

Hello Quasar,
As you can see from the documentation the current product design does not support interactive pre/post commands. This was done for a number of reasons, including the need for our software to track exit codes and the fact that the backup can be run in non-interactive mode (without anyone logged in) so there will be nothing to display.
This means that all pre/post commands are launched in a non-interactive mode which is why you won't see an interface.
Ways to work around this include running a non-interactive program that will be used to launch your desired interactive program.
For example, you can use the built-in Windows Task Scheduler:
- Create a task that runs your poweroff utility
- In the "General" tab, make sure you set "Run only when user is logged in". Otherwise, the Task Scheduler will also run programs in non-interactive and you'll be back where you started.
- The trigger can be a scheduled event far in the future, for example.
- Set the other settings as desired
- You can now run this task manually by issuing a command like this: schtasks /run /tn your_task_name
- It is enough to create a simple batch file with just the line above and set it as the post command.
- Anmelden, um Kommentare verfassen zu können

Thank you for your advice, Igor. The workaround I came up with is very similar to your suggestion. I have AB&R11 launch a post command batch script that taskkills a "non-essential" program that starts up with Windows. I am fortunate in that the Poweroff program provides an option to launch itself when a particular process ends, so when the task is killed with the batch script, Poweroff automatically launches and I get the result I'm wanting. Thank you for your explanation as I was going crazy trying to figure out why Acronis wouldn't launch it directly via script.
- Anmelden, um Kommentare verfassen zu können

Igor, one suggestion I have for the Acronis team is to make the Pre/Post Command "Test Command" button more closely mirror ABR's actual behavior. Speaking for myself, and seeing posts on the forum from lots of other users about this as well, when a function works as expected using the "Test Command" button but then does not work in actual usage in ABR is very frustrating and confusing for users. For example in my case, if ABR is designed to not show interactive programs during pre/post command execution, it shouldn't when clicking the "Test Command" button either. Just my 2 cents. Thanks
- Anmelden, um Kommentare verfassen zu können

Hello Quasar,
Thank you for your feedback! I agree that this can be very confusing and we'll take this into account in a future update of the product.
- Anmelden, um Kommentare verfassen zu können