Script to backup PST files w/ vshadow.exe

I need a script that uses CopyWithVSS.cmd (the code below) and vshadow.exe to backup  multiple PST files -i've tried this in the past and I could not get it to work...
@REM test if we are called by VSHADOW 
@REM Get the source and destination path 
@REM Create the shadow copy - and generate env variables into a temporary script. 
@REM Then, while the shadow is still live 
@REM recursively execute the same script. 
@echo ...Determine the scripts to be executed/generated... 
set CALLBACK_SCRIPT=%~dpnx0 
set TEMP_GENERATED_SCRIPT=GeneratedVarsTempScript.cmd 
@echo ...Creating the shadow copy... 
@goto :EOF 
@REM This generated script should set the SHADOW_DEVICE_1 env variable 
@echo ...Obtaining the shadow copy device name... 
@REM This should copy the file to the right location 
@echo ...Copying from the shadow copy to the destination path... 

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sounds to me like you have PST files that are being used by users over the network.  This is not a supported configuration.  Move each user's PST file to their PCs and install the PST Backup utility (free download from  That will then copy the PST files to the server for you when the user closes Outlook.  The files on the server won't be locked so you won't have a problem backing them up.
rick2021Author Commented:
No these are PST files that are local on the user's computer...we need it backed up to a server not an exchange server we are currently using this snippet of code but all it does is make the folder and it doesnt back up anything...
Dim strFolder 
Dim objNetwork 
Set objNetwork = CreateObject("WScript.Network") 
strFolder = "C:\" 
Set objFso = CreateObject("Scripting.FileSystemObject") 
Set objFolder = objFso.GetFolder(strFolder) 

If Not objFSO.FolderExists("c:\PST") then
	Set PSTFolder=objFSO.CreateFolder("c:\PST")
End if

For Each objFile In objFolder.Files 
 If UCase(objFso.GetExtensionName(objFile.Path)) = "PST" Then 
   Set objShell = WScript.CreateObject("WScript.Shell") 
   objShell.Run("c:\CopyWithVss.cmd """  & objFile.Path & """C:\pst"), 1, True 
 End If 

Open in new window

Exactly what the PST Backup utility is designed for.
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

rick2021Author Commented:
This utility does not do it if Outlook is open which is exactly what we need it to do - we are using a piece of backup software called Robocopy...we need it to use the code above or something that works with the vshadow and CopyWithVSS.cmd code...we really need this.
Steve KnightIT ConsultancyCommented:
Looking back I have a neglected alert for this but missed it at the time.   Could you try it from this simple batch file to see if it gives any pointers:

@echo off

REM Make dir if it doesn't exist
mkdir c:\PST 2>NUL

REM set StartPath for drive scan for PST's
CD C:\

REM Scan for all PST files under this start dir.  Exclude any in c:\pst\
for /R %%a in (*.PST) DO (
  echo Found %%~nxa at %%~dpa...
  if /i NOT "%%~dpa"=="c:\pst\" call c:\copywithvss.cmd "%%a" "c:\pst"

If you want it to do something different then let us know.

I am currently running this script in my environment, with Win XP, and my users have multiple and large PST files.
What I did was write a few additional scripts and used scheduled tasks to complete this.

One thing i did notice different in your script was this line:

My users are not admins so i used a program called lsrunase.exe to run the scripts as an admin

I placed all my files in a folder c:\tools which is hidden which included
Vshadow.exe, robocopy.exe, CopywithVSS.cmd, robocopy_pstsync.bat,vassadmin.bat, vssrun.bat

VSSadmin.bat (c:\tools\lsrunase.exe srvacctname domain password "c:\tools\vssrun.bat")
VSSRun.bat (c:\tools\CopyWithVSS.cmd c:\Outlook_PST\ c:\Outlook_PSTBackup>>C:\Tools\VSS.log)

The CopywithVSS.cmd is used to make a local copy from C:\Outlook_PST to c:\Outlook_PSTBackup it will also generate a log file to confirm if it ran or not.

With those files in place we scheduled to copy the PST files over at night after the user has left, cuts down on peak time bandwidth issues.

SCHTASKS /Create /SC daily /TN Robocopy /ST 19:00:00 /TR "c:\tools\robocopy_pstsync.bat"
 this was designated for desktop users who were instructed to leave their PC’s on at night

SCHTASKS /Create /SC weekly /D MON,TUE,WED,THU,FRI /TN VSS /ST 09:00:00 /TR "c:\tools\vssadmin.bat" /RU domain\srvacct /RP password
this was for laptop users to make copies every morning to have a good backup in case of corruption before it was copied later in the day

SCHTASKS /Create /SC daily /MO 2 /TN Robocopy /ST 12:00:00 /TR "c:\tools\robocopy_pstsync.bat" /RU domain\srvacct /RP password  
this was for laptop users and theirs would copy up at lunch time of every second day of the week

robocopy_pstsync.bat  (c:\tools\robocopy c:\Outlook_PSTBackup\ \\servername\share /V /NP /XO /R:1 /W:1 /LOG+:\\servername\share\ username.log)
 this is the task that would run at night and create a log file with history of the success or fail of the copy.

I know there is a lot of info here, if you have any questions on any of these files or additional scripts let me know.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Guy Hengel [angelIII / a3]Billing EngineerCommented:
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Storage Software

From novice to tech pro — start learning today.