Batch File

95 pts.
Tags:
.PST files
Batch 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.
ASKED: April 3, 2008  11:18 AM
UPDATED: September 25, 2008  10:21 AM

Answer Wiki

Thanks. We'll let you know when a new response is added.

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] </i> [/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.

Discuss This Question: 7  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Lonewolfbw
    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: http://www.neurophys.wisc.edu/comp/blog/bb20070403_01.asp 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.)
    525 pointsBadges:
    report
  • Jjjjjjjj
    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
    95 pointsBadges:
    report
  • Labnuke99
    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
    32,960 pointsBadges:
    report
  • Labnuke99
    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.
    32,960 pointsBadges:
    report
  • David Sengupta
    You could just use this tool: http://www.microsoft.com/downloads/details.aspx?FamilyID=8b081f3a-b7d0-4b16-b8af-5a6322f4fd01&displaylang=en David
    1,355 pointsBadges:
    report
  • Charmed
    hi jjjjjjj this batch didn't work out coz their is a invalid parameters the xcopy cant support the space between the "Documents and Settings" so all you have to do is copy the outlook.pst to c:\outlook\ and create this batch file that i have gave you ------------------------------ taskkill /im outlook.exe xcopy “C:\Documents and Settings\Administrator\Local Settings\Application Data\Microsoft\Outlook\Outlook.pst” “Z:\outlook.pst /y ----------------------------------- this well work 1000% i have try it so good luck :-) @echo off taskkill /f /t outlook.exe echo Starting copy operation cd C:\Outlook\Outlook.pst xcopy *.* /s /e /y /c z:\Outlook\ echo Copy operation complete pause > nul
    35 pointsBadges:
    report
  • Charmed
    sorry jjjjjjjjjjjj i have to tell you must configured the outlook to the new location . good luck :->
    35 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following