I'm trying to convert a BATCH file I am still working on (question at Robocopy | Mirror Destination Including Source Parent Folder).
I've made some progress, and the reason I moved to VB is to add a bit more functionality, like adding a dialog box to ask the user to browse for a folder they'd like to backup...
Now the code I currently have (only partially converted from my original .bat file);
Dim Command1
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder(0, "Example", 1, "c:\Programs")
If objFolder Is Nothing Then
Wscript.Quit
End If
wscript.Echo "folder: " & objFolder.title & " Path: " & objFolder.self.path
sCmd = "%windir%\System32\Robocopy.exe "
sDate = Day(Now) & "-" & Month(Now) & "-" & Year(Now)
sTime = Hour(Now) & "-" & Minute(Now) & "-" & Second(Now)
sSource = objFolder & " "
sDestination = "Backups\"& Year(Now) &"\"& Month(Now) &"\"& Day(Now) &"\ "
sLogDir = "Backups\Logs\"& Year(Now) &"\"& Month(Now) &"\"& Day(Now) &"\ "
sSwitches = "/SEC /E /Log:"& sTime &".txt"
Set objShell = CreateObject("Wscript.Shell")
objShell.Run(sCmd & sSource & sDestination & sSwitches)
My issue is that this is what happens according to the log file;
Source = G:\test\delete\
Dest = G:\test\Backups\2013\10\23\
Meanwhile the true source is;
C:\Users\User\Desktop\delete
So what I'd like to try to figure out is why it is affixing "G:\test", the folder the .vbs is being run from, to its source.
All in all, my goal is to just have Robocopy copy files, but the source is based on user input (hence the select a folder option). I would also like to add a "destination" option, that you specify where to backup to... But that is really optional, I'm sure I can figure that out if I get this first issue sorted.
Thanks in advance for any and all assistance!