手机
当前位置:查字典教程网 >脚本专栏 >vbs >定时自动备份IIS的WWW日志的vbs脚本
定时自动备份IIS的WWW日志的vbs脚本
摘要:dimIISCount,IISObject,logfiledir,fso,LogFilePeriods,inputtime,site,sit...

dimIISCount,IISObject,logfiledir,fso,LogFilePeriods,inputtime,site,sites,i,j,sitename(999),WshShell

'onerrorresumenext

setWshShell=WScript.CreateObject("WScript.Shell")

Setfso=CreateObject("scripting.FileSystemObject")

setIISCount=GetObject("IIS://localhost/w3svc")

sites=0

foreachsiteinIISCount

if(site.class="IIsWebServer")then

sitename(sites)=site.name

sites=sites+1

endif

next

MsgBox"IIS中一共"&sites&"个站点,ID分别为:"

forj=1tosites-1

MsgBoxsitename(j)

next

inputtime=inputbox("您要备份哪天的日志?如备份2004-01-01,则输入040101")

MsgBox"备份"&inputtime&"天的日志"

MsgBox"开始备份.............."

fori=0tosites-1

SetIISOBJect=GetObject("IIS://localhost/w3svc/"&sitename(i))

MsgBox"备份ID="&sitename(i)&"Sitename="&IISObject.servercomment&"的站点"

logfiledir=IISObject.LogFileDirectory&"w3svc"&sitename(i)'设置第一个站点的日志路径

if(Err.Number<>0)thenlogfiledir=IISCount.LogFileDirectory

Err.clear

'ifIISObject.LogFilePeriod=1thenLogFilePeriods="days"

'ifIISObject.LogFilePeriod=2thenLogFilePeriods="weeks"

'ifIISObject.LogFilePeriod=3thenLogFilePeriods="months"

'ifIISObject.LogFilePeriod=4thenLogFilePeriods="hours"

'ifIISObject.LogFilePeriod=0ANDIISObject.LogFileTruncateSize=-1thenLogFilePerirods="onefile"

'ifIISObject.LogFilePeriod=0ANDIISObject.LogFileTruncateSize>0thenLogFilePerirods="size"&IISObject.LogFileTruncateSize

LogFilePeriods=IISObject.LogFilePeriod

if(Err.Number<>0)thenLogFilePeriods=IISCount.LogFilePeriod

Err.clear

if(NOTLogFilePeriods=1ANDNOTLogFilePeriods=4)then

MsgBox"对不起,您的日志偶就不给备份,咋地吧"

WScript.quit

endif

if(NOTfso.folderexists("d:backup"))then

MsgBox"thefolderd:backupisnotexist,nowcreateit"

fso.CreateFolder("d:backup")

Msgbox"createdd:backupsuccuful"

endif

if(NOTfso.FolderExists("d:backup"&IISObject.servercomment))then

MsgBox"thefolderd:backup"&IISObject.servercomment&"isnotexist,nowcreateit"

fso.CreateFolder("d:backup"&IISObject.servercomment)

MsgBox"createdd:backup"&IISObject.servercomment&"succuful"

endif

MsgBox"nowbackupthelogfiles"

logfiledir=WshShell.ExpandEnvironmentStrings(logfiledir)'将环境变量转换成字符串

MsgBoxlogfiledir

fso.Copyfilelogfiledir&"ex"&inputtime&"*","d:backup"&IISObject.servercomment

ifErr.number<>0then

MsgBox"thissitenofiles"

else

MsgBox"backuplogfilessuccuful"

endif

inputifdel=inputbox("是否删除已备份文件?输入“YES”进行删除")

ifinputifdel="YES"then

fso.DeleteFile(logfiledir&"ex"&inputtime&"*")

MsgBox"删除文件成功"

else

MsgBox"文件已保留"

endif

next

MsgBox"备份所有的日志文件成功,嘿嘿"

【定时自动备份IIS的WWW日志的vbs脚本】相关文章:

多进程的实现投票的vbs脚本

文件夹定时自动备份 AutoBackUpFolder.vbs

文本文件分割脚本(VBS)

vbs实现的定时提醒你休息的脚本

解锁注册表的vbs脚本

用vbs实现本地添加用户的脚本

用vbs实现的exe2swf工具脚本代码

清除垃圾的VBS文件 自动查找多个盘

打开QQ并且让它自己输入用户名和密码的vbs脚本

写个设置命令的VBS脚本代码

精品推荐
分类导航