Vbscript to query old and large log files in C drive
<p>I have wrote a vbscript to query OldLogfiles and LargeLogfiles from C drive of the server and delete logs which is older than 6 months.But the script not seems to be working fine.I am not very good at scripting.Can anyone help me to fix the issue with below vbscript ?</p>

<pre><code>strComputer = "."
Dim objFile,iDaysOld,item,objFSO,dateTime
Dim FileName,FileName1,Logs,GetFile,file
iDaysOld = 180
Set dateTime = CreateObject("WbemScripting.SWbemDateTime")
Set wmi = GetObject("winmgmts:\\.\root\cimv2")
Set files = wmi.ExecQuery("Select * from CIM_DataFile Where Extension='log' AND Drive='C:'")
For Each file in files
    If LCase(Right(Cstr(File.Name), 3)) = "log" Then
        FileName1 = Trim(File.Name)
        FileName = (File.Name &amp; "," &amp; FileName)
        wscript.echo FileName
        If file.LastModified &lt; (Date() - iDaysOld) Then
' oFile.Delete(True) 
            wscript.echo "tr_Oldlogfiles=" &amp;FileName
        End If 
    End If 
Next
</code></pre>