Solved Need backup batch for Vista

I need separate backup batch scripts for XP and Vista/Win7. Given any one of the OSes, I think I can modify the script to accommodate the other.

My goal is a script that will backup specific OS directories to an external drive for each non-default user account (including Owner). I'd like the script to either scan the OS for non-default account names, or read each account name from an array in the script, or read the account names from an external text file, I want to save the following OS directories

desktopdocumentsfavoritesmusicpicturesvideos

Any assistance with such a script will be greatly appreciated. Thanks.

This script will try to identify the os version based on the file structure. I realize there are better ways of doing that, but I wrote this in about 2 minutes. Once it identifies the os, it runs a series of robocopy commands to backup the directories you wanted to drive f:. This script is not tested, and you will have to tweak it to your specifications.

@echo off

setlocal

REM Making sure robocopy.exe exists in %systemroot%\system32REM ***IMPORTANT*** robocopy.exe must be stored in the same directory as this script

Thank you for your prompt response, jowah. Your solution looks promising. However, I'd like to discuss some modifications to make it more specific to my needs.

1.) The reason I wanted to script my backup was to increase my success in case the OS was unstable or infected to the point that installing 3rd party software might be a problem. I'd like to know if I can modify your script to use xcopy instead of robocopy.

2.) Since you're creating a user.tmp file to hold user accounts, I'd like to know if I it's OK to simply create user.tmp myself and populate it with the user accounts whose data I want to save.

3.) If #2 is feasible, could I delete the conditional statements that check for default accounts?

Your script appears to be everything I need, and I especially like that it works for XP, Vista and Win7. Thank you so much.

1.) Yes you can substitute xcopy for robocopy. The syntax is different so you'll have to modify those statements, but xcopy should work just as well as robocopy.

2.) Yes you can manually create users.tmp. I put a "REM " (without the quotes, like lines 5 & 6) in front of the lines you don't need. That way you can just remove the REM if you ever decide to use those lines again.

3.) Yes. See the new script below. Now all you need to do is create the correct syntax xcopy commands and place them at the indicated points.

@echo off

setlocal

REM Making sure robocopy.exe exists in %systemroot%\system32REM ***IMPORTANT*** robocopy.exe must be stored in the same directory as this script

Here is my modified backup batch file. Unfortunately, I get the following error when ran:

"*) was unexpected at this time."I assume it is referencing the following line:"for /f (tokens=*) %%a in "users.tmp" do ("

I created a file, users.tmp containing only the word, Owner. It is located in the same directory as the script. I don't understand why I'm getting the error and would like someone to parse my batch code for answers. Thanks.

Thanks again for your prompt reply, jowah. I was able to fix the script issues as follows:

1.) changed (tokens=*) to "tokens=*"2.) changed "users.tmp" to (users.tmp)3.) changed "exist" order for XP and Vista/7 so that Vista/7 was checked first since "documents and settings" evaluates=true for both XP and Vista/7, which caused an "access denied" when Vista tried to access the "c:\documents and settings" directory instead of "c:\users".4.) closed DO loop parentheses

The final working script follows. jowah I really think your script will be a big help to everyone who needs to do a quick backup. Thanks again for all your efforts.

The information on Computing.Net is the opinions of its users. Such
opinions may not be accurate and they are to be used at your own risk.
Computing.Net cannot verify the validity of the statements made on this
site. Computing.Net and Compnet Ventures, LLC hereby disclaim all responsibility
and liability for the content of Computing.Net and its accuracy.