我曾经在 Robocopy 中使用一行,它允许我复制文件夹中的所有文件夹,包括父文件夹,即 Blackberry 文件夹中的所有文件/文件夹,包括 Blackberry 文件夹本身,否则它只会复制其中的文件和将它们转储到备份位置...
使用的代码是;
for %%a in ("%source%") do SET destination="Backups\%date%\%%~nxa"
现在在 VB 脚本中,我得到了;sSource = Chr(34) & objFolder.self.Path & Chr(34) & " "
那么我将如何让 VB 脚本(仍称为 Robocopy)使用上述内容,以便在备份时也包含 PARENT 文件夹?
这是我的代码;将 Robocopy 批处理转换为 VB 脚本
提前致谢!
编辑:我的脚本文件的当前内容;
Dim BrowseBackupSource
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder(0, "Please browse to the folder you would like to backup.", 1, "C:\")
If objFolder Is Nothing Then
Wscript.Quit
End If
wscript.Echo "folder: " & objFolder.title & " Path: " & objFolder.self.path
Dim BrowseBackupLocation
Set objShell = CreateObject("Shell.Application")
Set objDest = objShell.BrowseForFolder(0, "Please browse to the folder you would like to save the backup to.", 1, "C:\")
If objDest Is Nothing Then
Wscript.Quit
End If
wscript.Echo "folder: " & objDest.title & " Path: " & objDest.self.path
sCmd = "%windir%\System32\Robocopy.exe "
sDate = Day(Now) & "-" & Month(Now) & "-" & Year(Now)
sTime = Hour(Now) & "-" & Minute(Now) & "-" & Second(Now)
sSource = Chr(34) & objFolder.self.Path & Chr(34) & " "
sDestination = Chr(34) & objDest.self.Path & Chr(34) & " "
sSwitches = "/E /Log:"& sTime &".txt"
Set objShell = CreateObject("Wscript.Shell")
objShell.Run(sCmd & sSource & sDestination & sSwitches)