Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Difference between NA and European VBScript?

Status
Not open for further replies.

cmwoodman

IS-IT--Management
Sep 20, 2000
32
US
I have a vbscript that i use to monitor server information (event logs, drive space, etc.) that works very well here in the US. The problem is when i place it on our servers in the UK, it does not want to work properly.

Specifically, I run a query on the event logs to look in the logs for the past 24 hours and find anything that has an error or warning. on US servers no problem. on the UK servers it finds everything prior to 24 hours. any ideas?
 
Are you perchance working with a date? If so, remember that US date format is not used worldwide...
 
One thing comes to mind right away.

Some people write scripts relying on manipulation of dates as text instead of as dates. When converting a date to text they sometimes make assumptions about the format - but for "short dates" the US default is M/D/Y while in the UK and other locales it is D/M/Y.

The same thing can happen with text pulled from things like log files.

Maybe this is a factor in your case? How are you extracting/selecting the desired records?
 
here is the the section of the code that is giving me fits.


defining of the range var

cutoff = date()-1

then the retrieval of the logs

For Each objEvent in colLoggedEvents
if WMIDateStringToDate(objEvent.TimeGenerated) >= CutOff Then
Do While mycounter < 20
mycounter = mycounter + 1
noevents = &quot;events&quot;
res.Writeline (&quot;<TR>&quot;)
res.Writeline (&quot;<TD><font face=Verdana color=#000080 size=1> &quot; & objEvent.ComputerName & &quot;</font></TD>&quot;)
res.Writeline (&quot;<TD align ='center'><font face=Verdana color=#000080 size=1> &quot; & objEvent.EventIdentifier & &quot; / &quot; & objEvent.LogFile &&quot;</font></TD>&quot;)
res.Writeline (&quot;<TD><font face=Verdana color=#000080 size=1> &quot; & objEvent.SourceName & &quot;</font></TD>&quot;)
res.Writeline (&quot;<TD><font face=Verdana color=#000080 size=1> &quot; & WMIDateStringToDate(objEvent.TimeGenerated) & &quot;</font></TD>&quot;)
if objEvent.type = &quot;warning&quot; Then
res.Writeline (&quot;<TD align ='center' bgcolor=#FFFF00><font face=Verdana color=#000080 size=1> &quot; & objEvent.Type & &quot;</font></TD>&quot;)
Else
res.Writeline (&quot;<TD align ='center' bgcolor=#FF0000><font face=Verdana color=#000080 size=1> &quot; & objEvent.Type & &quot;</font></TD>&quot;)
End if
res.Writeline (&quot;<TD><font face=Verdana color=#000080 size=1> &quot; & objEvent.Message & &quot;</font></TD>&quot;)
res.Writeline (&quot;</TR>&quot;)
Loop
Else
End If

Next

this is the function that is susposed to format the dates, and i thought it was doing a pretty good job. in testing it is pulling the day first, then the month. and i can see it formatted like i want. i am just not pulling the logs i expect.


Function WMIDateStringToDate(dtmDate)
WMIDateStringToDate = CDate(Mid(dtmDate, 7, 2) & &quot;/&quot; & _
Mid(dtmDate, 5, 2) & &quot;/&quot; & Left(dtmDate, 4) _
& &quot; &quot; & Mid (dtmDate, 9, 2) & &quot;:&quot; & _
Mid(dtmDate, 11, 2) & &quot;:&quot; & Mid(dtmDate, _
13, 2))
End Function

I actually attempted to compensate for the difference in formatting dates between the two countries. but i just can't seem to nail down the problem. what i can get it to do is give me everything except the last 24 hours
 
-UPDATE-

Well i figured out what the problem was. Out of sheer frustration i just let the script run and gather info for the rest of the servers. I then stopped it after about 40 min. and looked at the output. It would seem that my bad results were only on the first server being checked. the rest were fine. on further investigation, the server had been set up with the wrong date. so current date, and eventlog dates were all wrong.

Thanks for your help
 
as a follow up i always use setlocale() at the start of my scripts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top