« To All the Violent Anti-Trump Protestors - Knock It Off | Main | Responding to Dennis Prager's Two Questions for Atheists »

How to Safely close Outlook Before Backup

Outlook IconI was working on some batch files to perform nightly backups. One of the issues was safely closing Outlook prior so that I could correctly copy the .pst file. Now, I know I could have used taskkill or .terminate in a vbs file, but those aren't safe ways to do it, and could have corrupted the .pst file. I did find some VB scripts that could close Outlook (such as here - Closing Outlook via a (scheduled) script), which worked fine when running them manually. However, when I tried to run those through Task Scheduler, I wound up getting an error, "ActiveX component can't create object: 'Outlook.Application' ", with an error code of 800A01AD, Microsoft VBScript runtime error. After many hours of researching (I'm not really an expert at this), I'm inclined to believe the comments in this thread, that's it's just unsupported and not possible.

However, I did find a simple workaround, a very simple program titled Close Outlook, available for download from that link. Just use the line 'start closeoutlook.exe' in the batch file, and it will start running in parallel with the rest of the batch file. I run it, then do backups of all my other folders before Outlook, giving Outlook plenty of time to close before it's time to do backup the .pst files. If you've left unsaved open drafts, Close Outlook won't actually close Outlook. You'll get a dialog box in Outlook asking you if you want to save the draft. I actually prefer that, since I don't want to lose those drafts, and missing one night of email backup usually is less troublesome than losing a draft email. But, it means that I had to use another little bit of code to check to see if Outlook was still running, to avoid trying to backup the PST file if it was:

tasklist /FI "IMAGENAME eq outlook.exe" 2>NUL | find /I /N "outlook.exe">NUL
IF "%ERRORLEVEL%"=="0" command

Anyway, after the amount of time I spent trying to figure this out, I thought it might save somebody else some time to know about that Close Outlook program.

Post a comment


TrackBack

TrackBack URL for this entry:
http://www.jefflewis.net/blog/jlnet-tb.cgi/935

Archives

Selling Out