Unstoppable Domains

Visual basic scripting - Beginner question

Spaceship Spaceship
Watch

domainwealth

Established Member
Impact
1
hi all - i found a script that's doing exactly what i need but the only issue i have with is is the date format. the date format is just a string but not mm/dd/yyyy.

does anyone know what i would need to add in order to convert it to mm/dd/yyyy?

i'll post the script instead of the link. not sure if posting the link is against tos ;)

really appreciate your help!!!


****************************************
' EventID12.vbs
' Version 1.9
' Guy Thomas 1st August 2010

Option Explicit

Dim objFso, objFolder, objWMI, objEvent ' Objects
Dim strFile, strComputer, strFolder, strFileName, strPath ' Strings
Dim intEvent, intNumberID, intRecordNum, colLoggedEvents

' --------------------------------------------
' Set your variables
intNumberID = 12 ' Event ID Number
intEvent = 1
intRecordNum = 1

strComputer = "."
strFileName = "\Event12.txt"
strFolder = "C:\GuyEbooks"
strPath = strFolder & strFileName

' ----------------------------------------
' Section to create folder to hold file.
Set objFso = CreateObject("Scripting.FileSystemObject")

If objFSO.FolderExists(strFolder) Then
Set objFolder = objFSO.GetFolder(strFolder)
Else
Set objFolder = objFSO.CreateFolder(strFolder)
Wscript.Echo "Folder created " & strFolder
End If
Set strFile = objFso.CreateTextFile(strPath, True)

'--------------------------------------------
' Next section creates the file to store Events
' Then creates WMI connector to the Logs

Set objWMI = GetObject("winmgmts:" _
& strComputer & "\root\cimv2")
Set colLoggedEvents = objWMI.ExecQuery _
("Select * from Win32_NTLogEvent Where Logfile = 'System'" )

Wscript.Echo " Press OK and Wait 30 seconds (ish)"
' -----------------------------------------
' Next section loops through ID properties
intEvent = 1
For Each objEvent in colLoggedEvents
If objEvent.EventCode = intNumberID Then

strFile.WriteLine ("Record No: ")& intEvent
' strFile.WriteLine ("Category: " & objEvent.Category)
strFile.WriteLine ("Computer Name: " & objEvent.ComputerName)
strFile.WriteLine ("Event Code: " & objEvent.EventCode)
' strFile.WriteLine ("Message: " & objEvent.Message)
' strFile.WriteLine ("Record Number: " & objEvent.RecordNumber)
strFile.WriteLine ("Source Name: " & objEvent.SourceName)
' strFile.WriteLine ("Time Written: " & objEvent.TimeWritten)
strFile.WriteLine ("Event Type: " & objEvent.Type)
strFile.WriteLine ("User: " & objEvent.User)
strFile.WriteLine (" ")
intRecordNum = intRecordNum +1
End if
IntEvent = intEvent +1
Next
Wscript.Echo "Check " & strPath & " for " &intRecordNum & " events"

WScript.Quit

' End of Guy's Script
*****************************
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
0
•••
I will find out the solution for this.:)
 
0
•••
Not sure if a solution is needed, but this should do the trick:

' strFile.WriteLine ("Time Written: " & objEvent.TimeWritten)

strFile.WriteLine ("Time Written: " & Format$(Now, "mm/dd/yyyy")

Replacing this line will give you today's date format.
 
0
•••
Dynadot โ€” .com Registration $8.99Dynadot โ€” .com Registration $8.99
Unstoppable Domains
Domain Recover
DomainEasy โ€” Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back