Login | |
|
 |
subtract 15 minutes from now - 3/10/2006 2:39:36 AM
|
|
 |
|
| |
ziminski
Posts: 79
Score: 2
Joined: 1/8/2006
Status: offline
|
I need to check a file to seeif it's been written to. By nature it is every second. when the process hangs the file is not updated and it's the only reliable way to now that it has hung is to check the time stamp on the file. So what I got is how to get the last time modified and I need to compare it to now - 15 minutes strDomain = "NORTHAMERICA" strUser = "useri" strPassword = "pswd" arrComputers = Array("Ucomp1","UScomp2") strLogFile = "D:\Synapps\Monitoring_Scripts\" & Split(WScript.ScriptName, ".")(0) & ".log" Set objFileSystem = CreateObject("Scripting.FileSystemObject") Set objLogFile = objFileSystem.CreateTextFile(strLogFile, TRUE) Dim logtime objLogFile.WriteLine(Now & ":" & vbTab & WScript.ScriptFullName & " Started.") Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator") 'For Each Comp In strComputer For Each strComputer In arrComputers Set objSWbemServices = objSWbemLocator.ConnectServer(strComputer, _ "root\cimv2", _ strUser, _ strPassword, _ "MS_409", _ "ntlmdomain:" + strDomain) Set colSwbemObjectSet = _ objSWbemServices.ExecQuery("Select * from CIM_Datafile Where name = 'D:\\Synapps\\Logs\\SynTCPServer.Log'") For Each objFile in colSWbemObjectSet logtime = Mid(objfile.LastAccessed,5,2) & "/" & mid(objfile.LastAccessed,7,2) & "/" & Mid(objfile.LastAccessed,1,4) & " " & Mid(objfile.LastAccessed,9,2) & ":" & Mid(objfile.LastAccessed,11,2)& ":" & Mid(objfile.LastAccessed,13,2) objLogFile.WriteLine logtime & "logtime" If logtime < (Now -15) Then <--this doesn't work objLogFile.WriteLine ("down") Else objLogFile.WriteLine ("up") End If Next Next Any help would be greatly appreciated! Rick
|
|
| |
|
|
|
|
|