定時(shí)自動(dòng)備份IIS的WWW日志的vbs腳本
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 & "個(gè)站點(diǎn),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 &"的站點(diǎn)"
logfiledir = IISObject.LogFileDirectory & "w3svc" & sitename(i)'設(shè)置第一個(gè)站點(diǎn)的日志路徑
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) '將環(huán)境變量轉(zhuǎn)換成字符串
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”進(jìn)行刪除")
if inputifdel="YES" then
fso.DeleteFile (logfiledir&"ex"&inputtime&"*")
MsgBox "刪除文件成功"
else
MsgBox "文件已保留"
end if
next
MsgBox "備份所有的日志文件成功,嘿嘿"
上一篇:用vbs實(shí)現(xiàn)的XP序列號替換器
欄 目:vb
下一篇:asp下去除數(shù)組中重復(fù)項(xiàng)的方法
本文標(biāo)題:定時(shí)自動(dòng)備份IIS的WWW日志的vbs腳本
本文地址:http://mengdiqiu.com.cn/a1/vb/7810.html
您可能感興趣的文章
- 01-10利用vbscript腳本修改文件內(nèi)容,此適用于自動(dòng)化的操作中
- 01-10利用VBS腳本自動(dòng)創(chuàng)建計(jì)算機(jī)帳戶的代碼
- 01-10可以定時(shí)自動(dòng)關(guān)機(jī)的vbs腳本
- 01-10vbscript自動(dòng)配置IIS的代碼
- 01-10用vbs實(shí)現(xiàn)定時(shí)運(yùn)行web文件的方法
- 01-10vbs定時(shí)發(fā)送郵件的方法與代碼
- 01-10使用ADSI、ASP和一對魔術(shù)戲法自動(dòng)地創(chuàng)立一個(gè)虛擬目錄的方法
- 01-10利用vbs自動(dòng)修改ip的代碼
- 01-10用vbs刪除前一天創(chuàng)建的備份文件
- 01-10用VBS可執(zhí)行程序+Xmlhttp下載備份網(wǎng)上文件的代碼


閱讀排行
本欄相關(guān)
- 01-10下載文件到本地運(yùn)行的vbs
- 01-10飄葉千夫指源代碼,又稱qq刷屏器
- 01-10SendKeys參考文檔
- 01-10什么是一個(gè)高效的軟件
- 01-10VBS中的正則表達(dá)式的用法大全 &l
- 01-10exe2swf 工具(Adodb.Stream版)
- 01-10VBS中SendKeys的基本應(yīng)用
- 01-10用VBSCRIPT控制ONSUBMIT事件
- 01-10VBScript教程 第十一課深入VBScript
- 01-10VBScript語法速查及實(shí)例說明
隨機(jī)閱讀
- 01-11ajax實(shí)現(xiàn)頁面的局部加載
- 01-10SublimeText編譯C開發(fā)環(huán)境設(shè)置
- 01-10delphi制作wav文件的方法
- 01-11Mac OSX 打開原生自帶讀寫NTFS功能(圖文
- 08-05dedecms(織夢)副欄目數(shù)量限制代碼修改
- 08-05織夢dedecms什么時(shí)候用欄目交叉功能?
- 08-05DEDE織夢data目錄下的sessions文件夾有什
- 01-10使用C語言求解撲克牌的順子及n個(gè)骰子
- 01-10C#中split用法實(shí)例總結(jié)
- 04-02jquery與jsp,用jquery