Batch file to backup outlook pst

tvanduzee

Member
May 8, 2013
25
0
0
Hello

Right now I have a batch file that closes outlook and copies the pst to a user folder on the server.
Problem is that I do not want to copy all pst files from each computer (some may be archives etc.. I only want the currently used pst.
Is there a line of code I can use to find the reg key that tells outlook where the data file is (pst)? Could be windows xp, 7 or 8

Currently, not all clients are consistent as to where the pst file is because there are different versions of windows. And the pst file is named by their email@address.com.pst (in most cases).

Code:
Rem vb script that closes all instances of outlook.
CloseOL.vbs

Rem give the outlook file time to close tmps
timeout /t 7 /nobreak

Rem if the destination folder does not already exist, create it.
if not exist %HOMESHARE%\Outlook Files mkdir %HOMESHARE%\Outlook Files

Rem Copies all PST files in the current users' profile to the network share
copy "%UserProfile%\Documents\Outlook Files\*.pst" "%HOMESHARE%\Outlook Files\*.pst" /y

pause

Rem Restarts Microsoft Outlook

start Outlook.exe
exit
Thank you for any help you can provide.

Terry
 
Last edited:

Tweak155

Lifer
Sep 23, 2003
11,449
264
126
If you are only concerned with copying native save location in each environment, you can check if the directories exist first.

If you want user specified locations - create a temporary PST on your computer in a new location that doesn't exist. Then scan REGEDIT values for that directory (make it something really unique so it is easy to find, like c\123abc567xyz).
 

sourceninja

Diamond Member
Mar 8, 2005
8,805
65
91
Have you thought about using powershell?

Export-Mailbox -Identity User.A -PstFolderPath C:\UserPST