hi,
im working on a script that pulls info from NTeventlog and writes it to a file.
my problem is that the "Time Written: "& objEvent.TimeWritten is in the following string
what can i do to format it mm/dd/yyyy hh:mm?
thank you in advance
im working on a script that pulls info from NTeventlog and writes it to a file.
Code:
Const ForAppending = 8
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
("C:\EventScript.txt", ForAppending, True)
'sets the file name and location
'
strComputer = "mymailserver"
'sets to local computer e.g. "."
'
'
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colLoggedEvents = objWMIService.ExecQuery _
("Select * from Win32_NTLogEvent Where Logfile = 'Application' and " _
& "EventCode = '1016'")
'Sets log file and Event ID Number
'
'
For Each objEvent in colLoggedEvents
objTextFile.WriteLine( "Computer Name: "& objEvent.ComputerName & vbCrLf _
& "Event ID: "& objEvent.EventCode & vbCrLf _
& "Time Written: "& objEvent.TimeWritten & vbCrLf _
& "Event Type: "& objEvent.Type & vbCrLf _
& "User: "& objEvent.User & vbCrLf _
& "Source: "& objEvent.SourceName & vbCrLf _
& "Descripition: "& vbCrLf & objEvent.Message & vbCrLf & vbCrLf)
objTextFile.WriteLine( "======================================================================================================================")
'Sets Event data to return
'
'
Next
objTextFile.Close
Const EVENT_SUCCESS = 0
Set objShell = WScript.CreateObject("Wscript.Shell")
objShell.LogEvent EVENT_SUCCESS, _
"Log wirten to file C:\EventScript.txt"
'Writes an event to app log with File Location
'
'
Wscript.Echo "Log wirten to file C:\EventScript.csv"
'echo File Location
'
my problem is that the "Time Written: "& objEvent.TimeWritten is in the following string
Code:
20061122232937.000000-300
what can i do to format it mm/dd/yyyy hh:mm?
thank you in advance