Showing results for 
Search instead for 
Did you mean: 

pre-command script suggestion?

Level 6
need a suggestion boost for a pre-command script:

I need a script to look and see if the MS Exchange Information Store service (store.exe) is running, and if it is not I need the script to fail.

I can query the status of the service, but what must I do to have the script fail (return error code) so that my backup job of the information store will not run if the service is not running?

I'm not looking to start the service, just cancel the job if the service is not running.

suggestions greatly appreciated...

Level 4
You could try PsService.exe using the "query" switch from By querying the "Microsoft Exchange Information Store" psservice will return the "state" of the service.

Level 6
Thanks, Sal I love the sysinternals tools too. However, psservice within a batch file will let me know a service is stopped, but I can't directly apply that in a pre-command. The command runs successfully, and then the backup jobs runs.

I need a command that will fail if a service is stopped, so that when used a pre command in backup exec it will not proceed with the job.

Thanks for your input!

Level 6
Hello Ray !

Why don't you use the option under Pre&Post commands settings in the backup job properties - > Run job only if pre-command is successful ?

Select this option to run the backup or restore job only if the pre-command is successful. If the pre-command fails, the job does not run, and is marked as failed.

If it is critical that the job does not run if the pre-command fails, then select Allow pre- and post-commands to be successful only if completed with a return code of zero. If a non-zero code is returned, it is interpreted by Backup Exec to mean that the pre-command did not run successfully. The job is not run and the job status is marked as Failed.


NOTE : If we do not receive your reply within two business days, this post would be marked assumed answered and would be moved to answered questions pool.