将以下脚本保存为vbs格式
********************************************************************************************
'备份系统状态,以日期命名,并删除早于指定日期的备份文件
strFolder = "D:\SystemBackup\"
strFileName = Date() &".BAK"
intKeepDay = 4
strBackupCmd = "Ntbackup.exe backup systemstate /J ""定时备份系统状态""" _
&"/F """ &strFolder &strFileName &""""
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strFolder)
Set objFiles = objFolder.Files
For Each objFile In objFiles
If objFile.DateCreated < Date() - intKeepDay And Right(objFile.Name,3) = "BAK" Then
objFile.Delete
End If
Next
Set objWshShell = CreateObject("WScript.Shell")
Return = objWshShell.Run(strBackupCmd,0,True)
If Return = 0 Then
objWshShell.LogEvent 0,Now() &" 备份系统状态成功"
Else
objWshShell.LogEvent 1,Now() &" 备份系统状态失败"
End If
***************************************************************************************************
脚本说明:
转载于:https://blog.51cto.com/wuxiaohui/424587