Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use vbs to automatically back up IIS WWW logs on a regular basis

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Editor to share with you how to use vbs to automatically back up IIS's WWW logs on a regular basis. I believe most people don't know much about it, so share this article for your reference. I hope you will gain a lot after reading this article. Let's learn about it together.

Dim IISCount,IISObject,logfiledir,fso,LogFilePeriods,inputtime,site,sites,i,j,sitename, 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 "Total in IIS" & sites & "sites The ID is: "for juni1 to sites-1 MsgBox sitename (j) next inputtime=inputbox (" which day's log do you want to back up? If you back up 2004-01-01, enter 040101 ") MsgBox" backup "& inputtime&" day log "MsgBox" to start the backup. " For iTun0 to sites-1 Set IISOBJect = GetObject ("IIS://localhost/w3svc/" & sitename (I)) MsgBox "backup ID=" & sitename (I) & "Sitename=" & IISObject.servercomment & "site" logfiledir= IISObject.LogFileDirectory & "w3svc" & sitename (I) 'set the log path of the first site if (Err.Number0) 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.Number0) then LogFilePeriods=IISCount.LogFilePeriod Err.clear if (NOT LogFilePeriods=1 AND NOT LogFilePeriods=4) then MsgBox "Sorry I will not back up your log. How about "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) 'converts the environment variable to the string MsgBox logfiledir fso.Copyfile logfiledir &" ex "& inputtime&" * "," d:backup "& IISObject.servercomment if Err.number0 then MsgBox" this site no files "else MsgBox" backup logfiles succuful "end if inputifdel=inputbox (" do you want to delete the backed up files? " Enter "YES" to delete ") if inputifdel=" YES "then fso.DeleteFile (logfiledir&" ex "& inputtime&" * ") MsgBox" delete files successfully "else MsgBox" files have been retained "end if next MsgBox" backup of all log files successfully, hey hey "above is" how to use vbs regular automatic backup of IIS WWW logs "all the contents of this article, thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report