VBScript调用WinRAR备份项目目录用日期作为文件名

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

Option Explicit
Function padLeft(str, length) 
If Len(str) >= length Then 
	padLeft = str
Else
	padLeft = padLeft("0"  + str, length)
End If
End Function

Dim fso,targetfile,c,rarfile,N,Date,WshScript,CurPath,ProjectFolder
N = Now
Date = CStr(Year(N)) & padLeft(CStr(Month(N)),2) & padLeft(CStr(Day(N)),2)
c=2
Set WshScript = CreateObject("WScript.Shell")
CurPath = ".\"
ProjectFolder = "ProjectName"
targetfile = CurPath + ProjectFolder + Date
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(targetfile & ".rar") Then
	Do while fso.FileExists(targetfile & "_" & c & ".rar")
		c = c + 1
	Loop
	rarfile = targetfile & "_" & c & ".rar"
Else
	rarfile = targetfile & ".rar"
End If
Set fso = Nothing
WshScript.Run """%ProgramFiles%\WinRAR\WinRAR.exe"" a " + rarfile + " " + CurPath + ProjectFolder
Set WshScript = Nothing