Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


subtract 15 minutes from now

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,32158
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> subtract 15 minutes from now
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 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
 
 
Post #: 1
 
 RE: subtract 15 minutes from now - 3/10/2006 2:45:11 AM   
  ebgreen


Posts: 5069
Score: 31
Joined: 7/12/2005
Status: offline
dteCutOffTime = DateAdd("n", -15, Now())

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to ziminski)
 
 
Post #: 2
 
 RE: subtract 15 minutes from now - 3/10/2006 2:57:57 AM   
  ziminski

 

Posts: 79
Score: 2
Joined: 1/8/2006
Status: offline
THANKS! Works like a charm.
I greatly apprecate you're fast reply!!

Give that man a prize!

(in reply to ebgreen)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> subtract 15 minutes from now Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts