Copy locked files - .PST .ost and the such RRS feed

  • Question

  • Using the following script, locked files such as outlook .pst or .ost can be copied whilst in use.


    Copy the following lines (down to just before 'Notes:') into notepad and save as SyncToyVSS.bat in directory C:\Program Files\SyncToy 2.0 Beta:






    FOR /F "tokens=1-3 delims=/:. " %%d IN ("%DATE%") DO set create_date=%%d%%e%%f

    FOR /F "tokens=1-4 delims=/:. " %%t IN ("%TIME%") DO set create_time=%%t%%u%%v%%w

    set SCRIPT=%create_date%%create_time%.cmd

    cd c:\Outlook


    vshadow.exe -script=%SCRIPT% -exec="C:\Program Files\SyncToy 2.0 Beta\SyncToyVSS.bat" C:


    @goto :EOF





    call %SCRIPT%


    @REM Copy individual file use: copy %SHADOW_DEVICE_1%\\test1\test.pst c:\test2\test.bak

    @REM or to copy whole directory content use:


    copy %SHADOW_DEVICE_1%\"\Documents and Settings\<user>\Local Settings\ApplicationData\Microsoft\Outlook" c:\Outlook


    del /f "%SCRIPT%"


    cd C:\Program Files\SyncToy 2.0 Beta

    SyncToyCmd -ROutlook




    Volume Shadow Copy Service SDK 7.2

    Use http://msdn2.microsoft.com/en-us/library/bb530725(VS.85).aspx

    Download here: http://www.microsoft.com/downloads/details.aspx?FamilyID=0b4f56e4-0ccc-4626-826a-ed2c4c95c871&displaylang=en

    Unpack, default should be in C:\Program Files\Microsoft\VSSSDK72,

    Copy two files: vshadow.exe and vshadow.pdb from C:\Program Files\Microsoft\VSSSDK72\TestApps\vshadow\bin\release-xp to C:\WINDOWS\system32


    As an example using the above script, create a temporary folder c:\Outlook – this will be the folder shadow copying will copy files to.

    Run SyncToy and setup a folder pair called Outlook to sync left folder c:\Outlook to right folder where you’ll sync to e.g. \\backup\Outlook

    Alter the following script to suit your directories that you’ll want copied e.g. for default PST or OST files location you’ll need to amend <user> to your logon name in the script on the ‘copy’ line.


    Finally setup a Scheduled Task to run SyncToyVSS.bat, to run in silent mode see this post:



    The script does not test for available free space so consideration required if copying complete directory.


    I run on MCE2005 with Office 2007 and is OK.


    Obviously amend script where necessary for your directories and file names etc.


    Kind regards, Jim.



    Wednesday, April 23, 2008 3:08 PM


  • Thanks for the great sample! 




    Wednesday, April 23, 2008 9:23 PM

All replies

  • Thanks for the great sample! 




    Wednesday, April 23, 2008 9:23 PM
  • Thank you for sharing the resolution.


    However, could you please tell how to include the subfolders (and its locked files) in that "main" folder".

    For example, I need to back up my whole skype profile @ C:\Documents and Settings\<user>\Application Data\Skype\<skype name> which also containing subfolders.

    Wednesday, June 25, 2008 11:25 AM
  • Brewster, there maybe a way but I'm not into scripting nor programming, so it maybe best to seek an answer from a scripting forum or check out M$ VSS library: http://msdn.microsoft.com/en-us/library/bb530726(VS.85).aspx

    Which has the following example:

    The following example shows how to enumerate all files on a shadow copy device from a batch file.

    1. dir > c:\somefile.txt
    2. vshadow -p -nw -script=SETVAR1.cmd c:
    3. call SETVAR1.cmd
    4. for /R %VSHADOW_DEVICE_1%\ %%i in (*) do @echo %%i



    Obviously you can just include seperate 'copy' lines for each sub-directory such as follows:


    copy %SHADOW_DEVICE_1%\"\Documents and Settings\<user>\Local Settings\ApplicationData\Skype\<skype dir name 1>" c:\Skype\<skype dir name 1>


    copy %SHADOW_DEVICE_1%\"\Documents and Settings\<user>\Local Settings\ApplicationData\Skype\<skype dir name 2>" c:\Skype\<skype dir name 2>




    Good luck!

    Saturday, June 28, 2008 8:40 AM
  • Hi,

    I have my .pst files on a client machine under the location -

    c:/documentsand setting/<user>/localsettings/applicationdata/microsoft/outlook

    I need one script to copy the same .pst file automatically to my server

    Please help

    Wednesday, April 1, 2009 10:16 AM