Jump to content

Batch File Writting Help


swancd

Recommended Posts

When a customer in our shop needs a reinstall we basically take their HDD out and put it in our machine to copy data off. Most people only want the folders detailed below to be backed up.

Looking for help writting a batch file.

The batch file needs to do the following.

1) Ask for drive letter.

2) Ask for Customers Name

3) Create a folder on D:\<customer name>

4) Copy the following folders: My Docs, Desktop, Favs, OE E-mails, Address Book, Outlook PST file if there is one.

It also needs to copy all user profiles from C:\Documents & Settings\<username>

Any ideas how and if this can be done.

Thanks

Link to comment
Share on other sites


Help suggests you already have done some work on this already! What have you got?

Also as this is for a business, were you considering payment to the person(s) responsible for helping in the production of this backup solution?

Link to comment
Share on other sites

Well, I won't charge--since chances are you would need to make modifications to this to work for you and also because I'm always willing to try to give back to the MSFN community for all the great stuff I've learned on this board.

This is a VBS script I use to do something similar to what your asking (I did make a few 'minor' changes based on your criteria).

What it does:

asks for a drive letter (I assume you were refering to the drive letter of the files TO BE copied, since you already specify the destination drive letter as 'D:').

asks for Customer name, will create folder, "D:\[customer name]\"

asks for profile: specifically the profile from the disk you want to back up (i.e. username). This script will backup one profile at a time and when finished ask if additional profiles need to be backed up.

Backups up the following folders to "D:\[customer name]\": (assume 'C' is assigned drive letter).

-C:\documents and settings\[profile]\My Documents

-C:\documents and settings\[profile]\Favorites

-C:\documents and settings\[profile]\Desktop

-C:\documents and settings\[profile]\Local Settings\Application Data\Microsoft\Outlook

Again, these are folders I commonly back up, with a few modifications you can edit/add the target destination folders, I may even be willing to help.

Copy and save as *.vbs

Set objFSO = CreateObject("Scripting.FileSystemObject")

strDriveLetter = InputBox("Please enter the desired drive letter","Drive Letter"," ")

strCustname = InputBox("Please enter the Customer name","Customer"," ")

strFolder1 = "D:\" & strCustname

Set objFolder1 = objFSO.CreateFolder(strFolder1)

CopyProfile()

i = 0

Do
strMbox = MsgBox("Would you like to copy another profile?",3,"Hostname")
If strMbox = 6 Then
CopyProfile()
i = 0
Else
i = 1
End If
Loop Until i = 1

WScript.Quit


'subroutine to perform the file backups
Sub CopyProfile()

strUsername = InputBox("Please enter the profile to copy","Username"," ")

strFolder2 = strFolder1 & "\" & strUsername
strFolder3 = strFolder1 & "\" & strUsername & "\My Documents"
strFolder4 = strFolder1 & "\" & strUsername & "\Favorites"
strFolder5 = strFolder1 & "\" & strUsername & "\Desktop"
strFolder6 = strFolder1 & "\" & strUsername & "\Outlook Data"

Set objFolder2 = objFSO.CreateFolder(strFolder2)
Set objFolder3 = objFSO.CreateFolder(strFolder3)
Set objFolder4 = objFSO.CreateFolder(strFolder4)
Set objFolder5 = objFSO.CreateFolder(strFolder5)
Set objFolder6 = objFSO.CreateFolder(strFolder6)

strTarget3 = strDriveLetter & ":\Documents and Settings\" & strUsername & "\My Documents\"
strTarget4 = strDriveLetter & ":\Documents and Settings\" & strUsername & "\Favorites\"
strTarget5 = strDriveLetter & ":\Documents and Settings\" & strUsername & "\Desktop\"
strTarget6 = strDriveLetter & ":\Documents and Settings\" & strUsername & "\Local Settings\Application Data\Microsoft\Outlook\"

On error resume next
Set newFolder3 = objFSO.GetFolder(strTarget3)
Set newFolder4 = objFSO.GetFolder(strTarget4)
Set newFolder5 = objFSO.GetFolder(strTarget5)
Set newFolder6 = objFSO.GetFolder(strTarget6)

On error resume next
newFolder3.Copy(strFolder3)
newFolder4.Copy(strFolder4)
newFolder5.Copy(strFolder5)
newFolder6.Copy(strFolder6)

End Sub

WScript.Quit

PS. My scripting knowlege is limited and self-taught--I'm sure there's a simpler way to script this, but I assure you this does work.

Edited by TheFlash428
Link to comment
Share on other sites

Nobody said anything about someone charging someone else. Asking for a fee would be just as rude as not offering one for a service which is only for commercial gain!

The questioner asked for help, not someone to do it for them!

Link to comment
Share on other sites

Nobody said anything about someone charging someone else. Asking for a fee would be just as rude as not offering one for a service which is only for commercial gain!

The questioner asked for help, not someone to do it for them!

I apologize if I implied that anyone suggested otherwise...I simply provided a script that I use to accomplish a task similar to what swancd had asked for, hoping it may be of some assistance to his quest to accomplish his goal.

Link to comment
Share on other sites

Big thanks to everyone.

Few modifications to get the Address Book & OE Messages and all working good now.

Would there be an "easy" way of displaying on the screen in some box or DOS window the files that are being copied.

With large files the screen is blank for ages while it copies in the background, would be good to ensure that it was actually copying the files!

Big thanks once again!

Link to comment
Share on other sites

Well, what you'll have is a backup copy on a second drive (you could actually use a network drive as well). Once the drive in question (the bad one), has been rebuilt, the files will have to be transfered back, manually.

Perhaps with a few modifications the script could run in reverse? Stand by...

Link to comment
Share on other sites

In addition to this is there anyway of creating an Outlook Express .iaf file using the above script?

Looks like you have to manually go to OE -> TOOLS -> ACCOUNTS -> MAIL -> EXPORT

Would be nice to include the .iaf file as part of the above data backup script.

Thanks in advance.

Link to comment
Share on other sites

Appriciate that. What we are trying to do is target "most" people!

We will advice that we backup ONLY these files unless otherwise specified. So if users use IncrediMail etc. etc. they will need to tell us so we can do things manually if needed.

Then again we could add it to the above script "just in case".

Thanks for reply.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...