'==========================================================================
'
' VBscript Source File -- Created with SAPIEN Technologies Primalscript 4.0
'
' NAME: Robocopy.vbs
'
' AUTHOR: Brandon Steili , www.netsyd.com
' DATE : 12/7/2005
'
' COMMENT: This script gives you the option of copying your my documents folder to
' your network drive, or copying your network drive to your my documents folder.
' The script requires Robocopy, and utilizes the /MIR /SEC switches. The only locations
' you need to edit to suit your network are in the subfunction at the end of the
' script. Username is determined automatically. There are a billion products that
' could do this, but none of them did quite what we wanted... so here it is.
'
'
' ==== Modification dates and users ====
'
' 12/8/05 Initial writing of script
'
'==========================================================================
Dim sourcedir,destinationdir,WshShell,Selection,robocopy,username
Set WshShell = Wscript.CreateObject("Wscript.Shell")
robocopy = """C:\Program Files\Resource Kit\robocopy.exe"""
username = Wshshell.ExpandEnvironmentStrings("%USERNAME%")
'Notify the user of the intentions
MsgBox (("** IMPORTANT **") & VbCrLf & VbCrLf & ("The Windows Resource Kit MUST be installed in C:\Program Files\Resource Kit\"))
'Get the user input for how to process
Selection = InputBox (("** IMPORTANT **") & VbCrLf & VbCrLf & ("Please select the mirror you wish to process") & VbCrLf & VbCrLf & ( "Press 1-- to move files from local to network") &_
VbCrLf & VbCrLf & ("Press 2 -- to move files from network to local") & VbCrLf & VbCrLf & ( "Press 0 -- If you wish to quit") & VbCrLf & VbCrLf & (""), 65, "")
If Selection = 0 Then
Wscript.Quit
Else
' Call the sub to determine the source and destination directories
SetFolders
'Process the files
WshShell.Run robocopy & " " & """" & sourcedir & """" & " " & """" & destinationdir & """" & " /MIR /SEC", , True
If Err.Number <> 0 Then
MsgBox ("** ERROR Received: **" & Err.number)
Wscript.Quit
Else
Err.Clear
End If
End If
MsgBox ("All Done. No Errors recieved.")
Sub SetFolders
Select Case Selection
Case(1)
sourcedir = "C:\documents and settings\" & username & "\My documents"
destinationdir = "\SERVERNAME\Users\" & username
Case(2)
destinationdir = "C:\documents and settings\" & username & "\My documents"
sourcedir = "\SERVERNAME\Users\" & username
Case else
MsgBox ("Invalid Seleciton. Exiting")
Wscript.quit
End Select
End Sub |