RDR-IT » Scripts » Vbs: IIS log rotation scriptVbs: IIS log rotation script 30 October 2018 - 25 March 2021 - Romain - (0) - 1 minute Unlike linux, Windows does not have a task for log rotation.Below is a Vbs script that allows you to do this rotation. '# source : https://docs.microsoft.com/en-us/iis/manage/provisioning-and-managing-iis/managing-iis-log-file-storage#delete-old-log-files-by-script sLogFolder = "c:\inetpub\logs\LogFiles" 'Emplacement des logs iMaxAge = 30 'Retention en jours Set objFSO = CreateObject("Scripting.FileSystemObject") set colFolder = objFSO.GetFolder(sLogFolder) For Each colSubfolder in colFolder.SubFolders Set objFolder = objFSO.GetFolder(colSubfolder.Path) Set colFiles = objFolder.Files For Each objFile in colFiles iFileAge = now-objFile.DateCreated if iFileAge > (iMaxAge+1) then objFSO.deletefile objFile, True end if Next NextIIS log rotate General IIS , vbs Similar articles