• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 343
  • Last Modified:

Automating backup of PST files to server

I'm trying to figure out a way to automatically back up a user's PST file to his or her home folder on the server when he or she logs off the network.  

Can this be done using VBScript?
  • 3
1 Solution
Easier than that !
You can create a batch file that will copy the pst to the desired location (it is better to map the network drive if possible). (use the old ods copy or xcopy function).
The using the scheduler (start > all programs > accessories > system tools > task sceduler) you can run your batch at desired time ...
Hi again,
the batch would look like something like this :

@echo off

copy c:\[your path to pst file] g:\path to the destination /v

Hi (again ...)
I didn't notice that you want this script to be run on logoff. It is easy to make it run on startup if you put the batch or a shortcut of the batch in the windows startup.
If you want to have it run at logoff you can setup up a gpo (go to run and type gpedit.msc then in the console go to User Configuration\Administrative Templates\System\Logon/Logoff)
use this application:


you can set it up so it backs up every time a user closes outlook.
mjbtecAuthor Commented:
I'll go with ngravatt's suggestion.

I did manage to make some scripts that back up the Outlook data to the server. I post them here.

Here's the VB Script version that detects the user name and copies all the PST files to the home folder.

Option Explicit
Dim objNetwork, objShell
Dim strDriveLetter, strUserName, strOutPath, strHome, strCom

Set objNetwork = WScript.CreateObject("WScript.Network")
strUserName = objNetwork.UserName
strOutPath="C:\Documents and Settings\" & strUserName & "\Local Settings\Application Data\Microsoft\Outlook\*.pst"
strHome= "\\server3\d$\home_folders\" & strUserName
strCom= "copy " & chr(34) & strOutPath & chr(34) & chr(32) & strHome

Set objShell = WScript.CreateObject("Wscript.Shell")
objShell.Run("%comspec% /c " & strCom)

I also made a version for AutoIt that's shorter but works just as well. AutoIt is a freeware scripting language that uses a BASIC-like language. It can be downloaded from http://www.autoitscript.com

$datapath ="C:\Documents and Settings\" & @UserName & "\Local Settings\Application Data\Microsoft\Outlook"
$copyto="\\server3\d$\home_folders\" & @UserName
FileCopy ($datapath & "\*.pst", $copyto,1)
FileOpenDialog ("PST Copy", "\\lrecdops-dc3\d$\home_folders\" & @UserName, "PST files (*.pst)")

I'll play with these scripts and see which works the best.

Thanks everyone for their help.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now