复制代码代码如下:
'/*=========================================================================
' * Intro 定时自动备份文件夹到一个以时间命名的新目录,设置好后加到启动项里,只要一启动机器程序就会自动运行,占系统资源可以不计
' * 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:/公司所有正在设计的系统", "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