Question

  Asked: Apr 3 2008   11:18 AM GMT
  Asked by: Jjjjjjjj


Batch File


Batch files, .PST files, Outlook

I need a Batch file that will help me backup my outlook pst files so I can schedule it to do the backup everyday at a particular time. I tried creating one but it wasnt successful. Please can anyone help me to write one that will run correctly.
Thanks.

Subscribe to Alerts! Get questions and answers delivered to your Inbox.


E-mail me updates on this question



   SUBSCRIBE

hidden modal window

Answer Wiki (Improve, edit or add to this answer)


 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0



You can use xcopy and also the task scheduler to manage the event. These are both part of the Windows OS.

xcopy has lots of switches:
Copies files and directory trees.

XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W]
[/C] [/Q] [/F] [/L] [/G] [/H] [/R] [/T] [/U]
[/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z]
[/EXCLUDE:file1[+file2][+file3]...]

source Specifies the file(s) to copy.
destination Specifies the location and/or name of new files.
/A Copies only files with the archive attribute set,
doesn't change the attribute.
/M Copies only files with the archive attribute set,
turns off the archive attribute.
/D:m-d-y Copies files changed on or after the specified date.
If no date is given, copies only those files whose
source time is newer than the destination time.
/EXCLUDE:file1[+file2][+file3]...
Specifies a list of files containing strings. Each string
should be in a separate line in the files. When any of the
strings match any part of the absolute path of the file to be
copied, that file will be excluded from being copied. For
example, specifying a string like \obj\ or .obj will exclude
all files underneath the directory obj or all files with the
.obj extension respectively.
/P Prompts you before creating each destination file.
/S Copies directories and subdirectories except empty ones.
/E Copies directories and subdirectories, including empty ones.
Same as /S /E. May be used to modify /T.
/V Verifies each new file.
/W Prompts you to press a key before copying.
/C Continues copying even if errors occur.
/I If destination does not exist and copying more than one file,
assumes that destination must be a directory.
/Q Does not display file names while copying.
/F Displays full source and destination file names while copying.
/L Displays files that would be copied.
/G Allows the copying of encrypted files to destination that does
not support encryption.
/H Copies hidden and system files also.
/R Overwrites read-only files.
/T Creates directory structure, but does not copy files. Does not
include empty directories or subdirectories. /T /E includes
empty directories and subdirectories.
/U Copies only files that already exist in destination.
/K Copies attributes. Normal Xcopy will reset read-only attributes.
/N Copies using the generated short names.
/O Copies file ownership and ACL information.
/X Copies file audit settings (implies /O).
/Y Suppresses prompting to confirm you want to overwrite an
existing destination file.
/-Y Causes prompting to confirm you want to overwrite an
existing destination file.
/Z Copies networked files in restartable mode.

The switch /Y may be preset in the COPYCMD environment variable.
This may be overridden with /-Y on the command line.

Maybe you can provide the batch file for review here.
  • AddThis Social Bookmark Button

Browse more Questions and Answers on Microsoft Windows and Exchange.

Looking for relevant Microsoft Windows Whitepapers? Visit the SearchWinIT.com Research Library.


Discuss This Answer


You must be logged-in to discuss a question. Log-in/Register

Lonewolfbw  |   Apr 3 2008  1:39PM GMT

Will XCOPY fail if the end user forgets to close down Outlook? That’s a concern I have with my own situation (working in a research facility where people usually leave their machines running 24/7 while experiments are in progress).

I have been experimenting with using NTBackup on a schedule for the same thing, since it makes use of the Shadowcopy service.

This was the reference I am currently working on:

<a href="http://www.neurophys.wisc.edu/comp/blog/bb20070403_01.asp" rel="nofollow">http://www.neurophys.wisc.edu/comp/blog/bb20070403_01.asp</a>

Though I have not gotten around the fact that NTBackup actually launches even though it’s called from a batch file. I have yet to find a way to make this run invisibly to the user if they are present. (And sadly, many are present at strange hours.)

 

Jjjjjjjj  |   Apr 3 2008  1:41PM GMT

Thanks for your answer.
This is the file i created. After closing outlook, it just goes off, not doing anything.

taskkill /im outlook.exe

xcopy “C:\Documents and Settings\Administrator\Local Settings\Application Data\Microsoft\Outlook\Outlook.pst” “Z:\outlook.pst /y

 

Labnuke99  |   Apr 3 2008  2:15PM GMT

Does the user have the ability to copy to the Z: location? Can you manually copy the file using the same command? I would also add the /V switch to verify the file as it copies. /F may also be useful to ensure the correct filenames are displayed.

Your batchfile is missing a quote after the Z:\outlook.pst:

xcopy “C:\Documents and Settings\Administrator\Local Settings\Application Data\Microsoft\Outlook\Outlook.pst” “Z:\outlook.pst /y

 

Labnuke99  |   Apr 3 2008  2:20PM GMT

Lonewolf - that is an excellent reference! Thanks for sharing. As you suggest, the one thing that is missing is automatically shutting down the outlook.exe application. Jjjjjj has found a way to do that it seems. You can also consider using one of the Microsoft Sysinternals tools called pskill.exe to perform this task immediately before kicking off the backup script. Let us know how it works.

 

David Sengupta  |   Apr 4 2008  3:41AM GMT

You could just use this tool: <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=8b081f3a-b7d0-4b16-b8af-5a6322f4fd01&displaylang=en" rel="nofollow">http://www.microsoft.com/downloads/details.aspx?FamilyID=8b081f3a-b7d0-4b16-b8af-5a6322f4fd01&displaylang=en</a>

David