Link to home
Start Free TrialLog in
Avatar of Member_2_4225740
Member_2_4225740

asked on

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?
Avatar of dlan75
dlan75
Flag of France image

Hi,
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)
ASKER CERTIFIED SOLUTION
Avatar of ngravatt
ngravatt
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Member_2_4225740
Member_2_4225740

ASKER

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)
WScript.Quit



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.