Note: depending on the folder size being copied it may take some time for the Copy Completed box to popup and will appear to be doing nothing while copying.
Dim FSO
Dim fREM, fLOC, cREM
Set FSO =
Wscript.CreateObject("Scripting.FileSystemObject")
cREM = InputBox("Enter the machine name", "Remote Name", "Laptop")
If cREM = False Then
msgbox "You pressed cancel"
Else
fLOC = "C:\Folder\Location"
fREM = "\\" & cREM & "\C$\Location"
msgbox "Copying to " & fREM
FSO.CopyFolder fLOC , fREM, True
msgbox "Copy completed"
End If
This can then be done without any user prompting to call a .bat file (or any other executable type file)
Dim FSO
Dim fREM, fLOC, cREM
Set FSO = Wscript.CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("WScript.Shell")
comp=oShell.ExpandEnvironmentStrings("%ComputerName%")
fLOC = "C:\Folder\Location"
fREM = "\\" & comp & "\C$\Location"
msgbox "Copying to " & comp
FSO.CopyFolder fLOC , fREM, True
oShell.Run ("C:\LocationofBatchFile.bat")
No comments:
Post a Comment