| |
u82cats
Posts: 5
Score: 0
Joined: 1/28/2007
Status: offline
|
This is my short, sweet, and nothing fancy VBS that uses old and new school techniques. This will backup a user’s info to their user folder. The only thing I would like to have on this would be some type of progress bar or animation while it works. ```````````````````````````````````````````````````````````````````````````` Set network = createobject("wscript.network") Set shell = CreateObject("wscript.shell") Set WshShell = WScript.CreateObject("Wscript.Shell") Set objFSO = CreateObject("Scripting.FileSystemObject") set filesys = CreateObject("Scripting.FileSystemObject") strUserProfile = Shell.ExpandEnvironmentStrings("%USERPROFILE%") 'Checks to see if U:\ is mapped, if not it maps it If objFSO.driveExists("U:\") Then Set objFolder = objFSO.GetDrive("U:\") Else Network.MapNetworkDrive "U:", "\\Servername\Users$\" & network.username End If 'Verifies Backup folder exist, if not it creates it If objFSO.FolderExists("U:\Backup") Then Set objFolder = objFSO.GetFolder("U:\Backup") Else Set objFolder = objFSO.CreateFolder("U:\Backup") 'pauses to allow for folder to be created before continuing WScript.Sleep 2500 End If 'Start message rc = MSGBOX ("This program will backup the contents of your My Documents, other files, and folders to your user folder on the local server.", 65, "Back Me Up!") 'looks for OK or Cancel if rc =1 then '1 is for OK 'Begin start log Const ForAppending = 8 Set filetxt = filesys.OpenTextFile("U:\Backup\Log.txt", ForAppending, True) filetxt.WriteLine"................................................." filetxt.WriteLine ("Task started by " & network.username & " on " & date & " at " & time) filetxt.WriteLine filetxt.Close 'End start log t1 = timer 'Starts Timer 'This is where the file copy starts WshShell.run "xcopy " & Chr(34) & struserprofile & "\My Documents\*.*" & Chr(34) & " " & Chr(34) & "u:\Backup\My Documents" & Chr(34) & " /d /e /i /y",0,True WshShell.run "xcopy " & Chr(34) & struserprofile & "\Favorites\*.*" & Chr(34) & " " & Chr(34) & "u:\Backup\Favorites" & Chr(34) & " /d /e /i /y",0,True WshShell.run "xcopy " & Chr(34) & struserprofile & "\Application Data\Microsoft\Proof\*.*" & Chr(34) & " " & Chr(34) & "u:\Backup\Proof" & Chr(34) & " /d /e /i /y",0,True WshShell.run "xcopy " & Chr(34) & struserprofile & "\Application Data\Microsoft\Signatures\*.*" & Chr(34) & " " & Chr(34) & "u:\Backup\Signatures" & Chr(34) & " /d /e /i /y",0,True WshShell.run "xcopy " & Chr(34) & struserprofile & "\Desktop\*.*" & Chr(34) & " " & Chr(34) & "u:\Backup\Desktop" & Chr(34) & " /d /e /i /y",0,True t2 = timer 'Ends Timer t2 = timer t3 = t2-t1 t4 = t3/60 t5 = round(t4, 2) 'translates to MM:SS 'Begin finish log Set filetxt = filesys.OpenTextFile("U:\Backup\Log.txt", ForAppending, True) filetxt.WriteLine ("Task finished on " & date & " in " & t5 & " MM:SS") filetxt.WriteLine "-------------------------------------------------" filetxt.Close 'End finish log 'End message and quit MsgBox "Files have finished backing up",, "Back Me Up!" wscript.quit else 'Begin canceled log Set filetxt = filesys.OpenTextFile("U:\Backup\Log.txt", ForAppending, True) filetxt.WriteLine "................................................." filetxt.WriteLine ("Task canceled on " & date & " at " & time) filetxt.WriteLine "-------------------------------------------------" filetxt.Close 'End canceled log and then quit wscript.quit end if `````````````````````````````````````````````````````````````````````````````````
|
|