Direkt zum Inhalt

Pre Batch file

Thread needs solution

I have some Outlook files in a Onedrive folder which Acronis will not backup. To get around the issue, I created a batch file that copies the pst files from Onedrive to another directory and backup the copy directory.

The backup works without the Pre batch file, but stalls with the batch file included. I also cannot close the cmd window.

What I am doing is closing Outlook, copying the batch files, then opening Outlook. Maybe someone can point out what I am doing wrong. This is the .bat file.

taskkill /IM outlook.exe /f

Copy C:\Users\user\OneDrive\Neville\Documents\Email\*.pst C:\Users\user\Documents\EmailBackup

cd "C:\Program Files (x86)\Microsoft Office\root\OFFICE16\"

OUTLOOK.EXE

taskkill /IM cmd.exe /f

Exit

0 Users found this helpful

Neville, take a look at forum topic: HOW-TO Back Up Outlook Data Files - posted by another user in the ATI 2020 forum recently which may be of help?  That topic is focussed on .OST files rather than .PST but the principle may be similar.

For your .bat file, you should not need to use the taskkill command to kill the CMD window as this should close by itself when the previous commands have completed successfully.

Example of a simple Pre Command to check for a drive being connected:

@echo off
if exist S:\ (exit /b 0)
exit /b 1

As the above shows, the exit command is used to terminate the batch script, and the /b 0 or 1 indicates success 0 or failure 1.

If you do need to kill the command window, then try the following line instead:

wmic process where name="cmd.exe" delete