| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| NamePros Member Join Date: Mar 2009
Posts: 29
![]() | visual basic scripting - beginner question 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)" ' ----------------------------------------- ????: NamePros.com http://www.namepros.com/programming/705524-visual-basic-scripting-beginner-question.html ' 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 *****************************
__________________ For Sale: SpringformPans.net |
| | |
| | #2 (permalink) |
| NamePros Regular Join Date: Nov 2007 Location: UK
Posts: 403
![]() ![]() ![]() | Unsure...but I'm going to post a link anyway! This may help... http://www.ms-news.net/f2891/turn-ob...e-3717967.html
__________________ 3cc Internet |
| | |
| | #3 (permalink) |
| NamePros Member Join Date: Mar 2011
Posts: 47
![]() | I will find out the solution for this.
__________________ █ A home to Virtual Machines! █ Onshore/Offshore Managed VPS █ Managed HardCore Ultimate VPS Offshore/Onshore |
| | |
| | #4 (permalink) |
| Senior Member Join Date: Sep 2007 Location: Chicago, IL USA
Posts: 682
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | 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. |
| | |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Visual Basic Question? | Domains4u | Programming | 7 | 12-19-2005 12:43 PM |
| Question regarding basic web design | sopiaz57 | Web Design Discussion | 12 | 02-25-2004 08:41 AM |
| Basic domain question | rak147 | Domain Newbies | 5 | 02-16-2004 01:37 PM |
| Basic Question! | bluey21 | Web Design Discussion | 3 | 02-16-2004 02:53 AM |
| Basic Question | hektor911 | Web Design Discussion | 7 | 02-16-2004 02:46 AM |