定時(shí)自動備份文件夾到一個(gè)以時(shí)間命名的新目錄,設(shè)置好后加到啟動項(xiàng)里,只要一啟動機(jī)器程序就會自動運(yùn)行,占系統(tǒng)資源可以不計(jì)。
代碼如下:
'/*=========================================================================
' * Intro 定時(shí)自動備份文件夾到一個(gè)以時(shí)間命名的新目錄,設(shè)置好后加到啟動項(xiàng)里,只要一啟動機(jī)器程序就會自動運(yùn)行,占系統(tǒng)資源可以不計(jì)
' * FileName AutoBackUpFolder.VBS
' * Author yongfa365
' * Version v1.0
' * Email yongfa365[at]qq.com
' * MadeTime 2009-05-14 17:18:33
' * LastModify 2009-05-14 17:18:33
' *==========================================================================*/
Do While 1
Run()
' WScript.Sleep 1000*60*60*2
WScript.Sleep 1000 * 5 '測試用,每5秒備份一次文件到指定的文件夾
Loop
Function Run()
BackUpFolder "D:\公司所有正在設(shè)計(jì)的系統(tǒng)", "E:\軟件自動備份"
End Function
Function BackUpFolder(S, D)
On Error Resume Next
Set FSO = CreateObject("Scripting.FileSystemObject")
FSO.CreateFolder D
FSO.CopyFolder S, D & "\" & GetDateFolder
End Function
Function GetDateFolder()
GetDateFolder = Year(Now) & "-" & Right("0" & Month(Now), 2) & "-" & Right("0" & Day(Now), 2) & "-" & Right("0" & Hour(Now), 2) & "-" & Right("0" & Minute(Now), 2) & "-" & Right("0" & Second(Now), 2)
End Function