VB script

  • Delete Old Date Files
  • set fs = createobject("scripting.filesystemobject")
    set fc = fs.getfolder("c:\news\output\")
    set f=fc.Files
    for each fi in f
       if (left(fi.name,1)="i") then
          if ((now-fi.datelastmodified)>2) then
            delFile = fi.Path
            fs.DeleteFile delFile
          end if
       end if
    next
    
  • Monitor Computer Processes
  • ''Usage:  cscript monitorprocess.vbs c:\process.log Servername
    ''Usage:  monitorprocess.vbs c:\process.log Servername
    Set objArgs = WScript.Arguments
    LogFile=objArgs(0)
    ServerName=objArgs(1)
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set FSOA = FSO.openTextFile(LogFile,2,True) 
    Set objWMIService = GetObject("winmgmts:\\" & ServerName & "\root\cimv2")
    Set colItems = objWMIService.ExecQuery("Select * from Win32_Process",,48)
    ''x= "GetObject(winmgmts:\\" & ServerName & "\root\cimv2)"
    ''FSOA.Writeline x
    count=1
    For Each objItem in colItems
    
    FSOA.Writeline cstr(Count) & " ,Process Name= " & objItem.Name & ",Process ID=" & objItem.ProcessId & ",Path=" & objItem.ExecutablePath
    
    count=count+1
    Next
    
    
    1