定时自动备份IIS的WWW日志的vbs脚本
作者 佚名
来源 ASP编程
浏览
发布时间 2013-07-09
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"备份所有的日志文件成功,嘿嘿" |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
上一篇: VBS编程教程 (第6篇)下一篇: 关于vbs WebBrowser导航问题
关于定时自动备份IIS的WWW日志的vbs脚本的所有评论