Fix: InetPub Folder consuming a lot of storage on Windows Server SBS 2011

The other day I was having a problem with a lot of space being consumed in the C Drive on a Windows 2008 SBS or Windows 2011 SBS version. I have noticed that the InetPub log files were taking more than 50GB of space. Now, there is an automatic way to delete these log and have a breath of fresh space. You can either use the below script to run it manually or set it up in a Scheduled task. This will stop the services and clear the logs… Swish, there it’s fixed. Enjoy.

@ECHO OFF
CLS
ECHO ** STOP IIS SERVICE **
NET STOP "TSGateway"
NET STOP "W3SVC"
ECHO ** DELETE OLD LOGS **
Forfiles.exe /P "C:\inetpub\logs\LogFiles\W3SVC1" /M *.log /D -5 /C "Cmd.exe /C del @path"
ECHO ** START IIS SERVICE **
NET START "W3SVC"
NET START "TSGateway"