How to safely delete IIS7 Logs

iis-7

I've google'd for this without much luck.. but I'm looking for an manual (one time run, free) / open source way to safely clear iis logs from /inetpub/logs/logFiles

I've seen ppl refer to isslogs.com, I have no idea how reliable that is, but even then I dont want any kind of scheduled task nor wish to pay for something i'm not really going to use often

I just want a simple safe way to delete all logs from inside the multiple folders in /inetpub/logs/logFiles

Recommendations or walkthroughs on how these can be removed would be appreciated.

Best Answer

Here is a script that deletes IIS logfiles older that 90 days

MaxDays = 90 
strComputer = InputBox("This script will delete IIS .log files over 90 days old "_ 
    & "from the machine you specify below.") 
wmiQuery = "Select * from Win32_OperatingSystem" 
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") 
Set colItems = objWMIService.ExecQuery(wmiQuery) 
    For Each objItem In colItems 
        sWindowsPath = objItem.WindowsDirectory 
    Next 
Set objW3SVC = GetObject( "IIS://" & strComputer & "/W3SVC") 
    For Each objSite In objW3SVC 
        If objSite.Class = "IIsWebServer" Then 
            strLogDir = UCase(objSite.LogFileDirectory) 
                strLogDir = Replace(strLogDir,"%WINDIR%",sWindowsPath,1,1,1) 
                strLogDir = Replace(strLogDir,"%SYSTEMROOT%",sWindowsPath,1,1,1) 
                strLogDir = Replace(strLogDir,":","$",1,1,1) 
            objLogFolder = "\\" & strComputer & "\" & strLogDir 
            Set oFSO = CreateObject("Scripting.FileSystemObject") 
            Set oFolder = oFSO.GetFolder(objLogFolder) 
            Set colSubFolders = oFolder.Subfolders 
            For Each oSubFolder In colSubFolders 
                If InStr(UCase(oSubFolder),"W3SVC") Then 
                    For Each oFile In oSubFolder.files 
                        If InStr(LCase(oFile.Name),".log") Then 
                             If (Date - oFile.DateCreated > CInt(MaxDays)) Then 
                                oFSO.DeleteFile(oSubFolder & "\" & oFile.Name) 
                            End If 
                        End If 
                    Next 
                End If 
            Next 
        End If 
    Next 
MsgBox("All done.")