Automating backup of PST files to server

Posted on 2007-10-02
Last Modified: 2010-04-08
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?
Question by:mjbtec
    LVL 12

    Expert Comment

    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 ...
    LVL 12

    Expert Comment

    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

    LVL 12

    Expert Comment

    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)
    LVL 10

    Accepted Solution

    use this application:

    you can set it up so it backs up every time a user closes outlook.

    Author Comment

    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

    $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.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Find out how to use dynamic social media in email signatures with this top 10 DOs & DON’Ts.
    Check out this infographic on what you need to make a good email signature that will work perfectly for your organization.
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now