Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Back Me Up

 
Logged in as: Guest
arrSession:exec spGetSession 2,16,46507
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> Post a VBScript >> Back Me Up
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Back Me Up - 4/30/2007 8:09:21 AM   
  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

`````````````````````````````````````````````````````````````````````````````````
 
 
Post #: 1
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> Post a VBScript >> Back Me Up Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts