Sign In with your
Trend Micro Account
Need Help?
Need More Help?

Create a technical support case if you need further support.

Automatically removing IIS logs created by the Integrated Smart Protection Service

    • Updated:
    • 18 Feb 2019
    • Product/Version:
    • OfficeScan XG
    • OfficeScan XG.All
    • Platform:
    • Windows 2003 Enterprise
    • Windows 2003 Standard
    • Windows 2008 Enterprise
    • Windows 2008 Standard
    • Windows 2012 Enterprise
    • Windows 2012 Web Server Edition

The Integrated Smart Protection Service (ISPS) creates and stores IIS logs in the W3SVC4 and W3SVC5 folders.

When deploying more than 1,000 smartscan clients and using the OSCE server's ISPS as the main Reputation server, the size of the IIS log file for these services will consume a significant amount of system drive space.


Create a Windows scheduled task that will delete the log files regularly:

  1. Save the script below as a vbs file on a local directory (i.e., delete_old_IISLogs_30days.vbs):
    On Windows Server 2008 and 2012, change the locations indicated on Call DeleteOldLogFiles to C:\inetpub\logs\LogFiles\ (default location).

    Option Explicit

    ' Delete all IIS Log Files older than 30 days
    Call DeleteOldLogFiles("C:\WINDOWS\system32\LogFiles\W3SVC3", 30)
    Call DeleteOldLogFiles("C:\WINDOWS\system32\LogFiles\W3SVC4", 30)
    Call DeleteOldLogFiles("C:\WINDOWS\system32\LogFiles\W3SVC5", 30)

    Function DeleteOldLogFiles(strPath2Logs, intDays2Keep)
    Dim fso, f, fc, f1, strFiles

    strFiles = ""

    Set fso = CreateObject("Scripting.FileSystemObject")
    If (fso.FolderExists(strPath2Logs)) Then
    Set f = fso.GetFolder(strPath2Logs)
    Set fc = f.Files

    '-- Determine if file is older than defined days
    For Each f1 in fc
    If DateDiff("d", f1.DateLastModified, Now) > intDays2Keep Then
    strFiles = strFiles & f1.Name & vbCrLf
    End If

    Set f1 = Nothing
    Set fc = Nothing
    Set f = Nothing
    End If
    Set fso = Nothing

    End Function

    A couple of changes was made especially in the "Delete all IIS Log Files older than 30 days" section. You can also change the logfile path and number of days (the current value is 30) based on your preferences.
  2. On the OSCE server, go to Control Panel > Scheduled Task.
  3. Double-click Add Scheduled Task, follow the wizard and provide the following information:
    1. Browse the script that Windows will execute: delete_old_IISLogs_30days.vbs
    2. Task Name: Delete IIS Logs older than 30 days
    3. Set Schedule: Daily
    4. Set Start Time: 00:00
    5. Set Start Date: <Same Day>
    6. Enter Domain Admin Credentials
  4. Click Finish.

The scheduled task will run daily starting at 00:00 on the day of creation.

Configure; Troubleshoot
Solution Id:
Did this article help you?

Thank you for your feedback!

*This form is automated system. General questions, technical, sales, and product-related issues submitted through this form will not be answered.

If you need additional help, you may try to contact the support team. Contact Support

To help us improve the quality of this article, please leave your email here so we can clarify further your feedback, if neccessary:
We will not send you spam or share your email address.

*This form is automated system. General questions, technical, sales, and product-related issues submitted through this form will not be answered.