- dim IISCount,IISObject,logfiledir,fso,LogFilePeriods,inputtime,site,sites,i,j,sitename(999),WshShell
- 'on error resume next
- set WshShell = WScript.CreateObject("WScript.Shell")
- Set fso = CreateObject("scripting.FileSystemObject")
- set IISCount=GetObject("IIS://localhost/w3svc")
- sites=0
- for each site in IISCount
- if (site.class="IIsWebServer") then
- sitename(sites)=site.name
- sites=sites+1
- end if
- next
- MsgBox "IIS中一共" & sites & "个站点,ID分别为:"
- for j=1 to sites-1
- MsgBox sitename(j)
- next
- inputtime=inputbox("您要备份哪天的日志?如备份2004-01-01,则输入040101")
- MsgBox "备份" &inputtime& "天的日志"
- MsgBox "开始备份.............."
- for i=0 to sites-1
- Set IISOBJect = GetObject("IIS://localhost/w3svc/" & sitename(i))
- MsgBox "备份ID=" & sitename(i) &" Sitename=" & IISObject.servercomment &"的站点"
- logfiledir = IISObject.LogFileDirectory & "w3svc" & sitename(i)'设置第一个站点的日志路径
- if (Err.Number<>0) then logfiledir=IISCount.LogFileDirectory
- Err.clear
- 'if IISObject.LogFilePeriod=1 then LogFilePeriods="days"
- 'if IISObject.LogFilePeriod=2 then LogFilePeriods="weeks"
- 'if IISObject.LogFilePeriod=3 then LogFilePeriods="months"
- 'if IISObject.LogFilePeriod=4 then LogFilePeriods="hours"
- 'if IISObject.LogFilePeriod=0 AND IISObject.LogFileTruncateSize=-1 then LogFilePerirods="onefile"
- 'if IISObject.LogFilePeriod=0 AND IISObject.LogFileTruncateSize>0 then LogFilePerirods="size"&IISObject.LogFileTruncateSize
- LogFilePeriods=IISObject.LogFilePeriod
- if (Err.Number<>0) then LogFilePeriods=IISCount.LogFilePeriod
- Err.clear
- if (NOT LogFilePeriods=1 AND NOT LogFilePeriods=4) then
- MsgBox "对不起,您的日志偶就不给备份,咋地吧"
- WScript.quit
- end if
- if (NOT fso.folderexists("d:backup")) then
- MsgBox "the folder d:backup is not exist,now create it"
- fso.CreateFolder("d:backup")
- Msgbox "created d:backup succuful"
- end if
- if (NOT fso.FolderExists("d:backup"&IISObject.servercomment)) then
- MsgBox "the folder d:backup" & IISObject.servercomment & " is not exist,now create it"
- fso.CreateFolder("d:backup" & IISObject.servercomment)
- MsgBox "created d:backup" & IISObject.servercomment &" succuful"
- end if
- MsgBox "now backup the logfiles"
- logfiledir = WshShell.ExpandEnvironmentStrings(logfiledir) '将环境变量转换成字符串
- MsgBox logfiledir
- fso.Copyfile logfiledir &"ex"&inputtime&"*","d:backup"& IISObject.servercomment
- if Err.number<>0 then
- MsgBox "this site no files"
- else
- MsgBox "backup logfiles succuful"
- end if
- inputifdel=inputbox("是否删除已备份文件?输入“YES”进行删除")
- if inputifdel="YES" then
- fso.DeleteFile (logfiledir&"ex"&inputtime&"*")
- MsgBox "删除文件成功"
- else
- MsgBox "文件已保留"
- end if
- next
- MsgBox "备份所有的日志文件成功,嘿嘿"
定时自动备份IIS的WWW日志的vbs脚本
2020-07-15 11:03VBS脚本之家 VBS
本文主要分享定时自动备份IIS的WWW日志的vbs脚本,极具参考价值,有需要的朋友可以了解下
延伸 · 阅读
- 2022-06-27python打印日志方法的使用教程(logging模块)
- 2022-03-07ELK监控nginx日志总结
- 2022-03-04python自动化测试通过日志3分钟定位bug
- 2022-03-02windows server 2019开启iis服务器+tp5.1的完美配置运行
- 2022-02-24WPS文字自动备份功能在哪?怎么设置自动备份和
- 2022-02-23Polysh命令实现多日志查询的方法示例
- VBS
雷客图ASP站长安全助手vbs测试版代码
雷客图ASP站长安全助手是一个基于ASP的帮助站长维护网站安全的程序。这个版本(vbs测试版)主要用于服务器本地运行以查找ASP木马。此版本为测试版,希...
- VBS
Adsutil.vbs 在脚本攻击中的妙用[我非我原创]
adsutil.vbs是什么?相信用过IIS的网管员不会不知道。这是IIS自带的提供于命令行下管理IIS的一个脚本。位于%SystemDrive%\Inetpub\AdminScripts目录下。...
- VBS
WINDOWS脚本实践:为SAP补丁制作的VBS脚本代码
本文主要分享WINDOWS脚本实践:为SAP补丁制作的VBS脚本代码,有需要的童鞋可以参考下...
- VBS
VBS数组深入浅出
VBS数组在应用中没有像其他语句那么广泛,VBS数组存在不少功能上的局限性(如二维数组的定义、赋值),在使用上也没有java等语言那么便捷...
- VBS
VBS编程教程 (第1篇)
VBScript的全称是:Microsoft Visual Basic Script Editon.(微软公司可视化BASIC脚本版). 正如其字面所透露的信息, VBS(VBScript的进一步简写)是基于Visual Basic的脚本语言....
- VBS
VBS文本文件操作实现代码
这篇文章主要介绍了VBS文本文件操作实现代码,需要的朋友可以参考下...
- VBS
VBS教程:正则表达式简介 -正则表达式语法
正则表达式语法 一个正则表达式就是由普通字符(例如字符 a 到 z)以及特殊字符(称为元字符)组成的文字模式。该模式描述在查找文字主体时待匹配的...
- VBS
灵活实用VBS入门教程应用篇
上一篇文章我们了解了VBS编程的一些基础知识,要更深入地学习还要学习选择结构和循环结构。 ...