Hi all. Keep getting the following error on WinXP boxes as well as my
Win2000 servers whenever I try to use vbs to read the event log: "
ActiveX component can't create object: 'GetObject'"

Heres the code I am using:

<html>
<head>
<title>OpLets v1.0</title>
</head>
<body>

<script type="text/vbscript">
<!-- event log -->
function eventlog
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2")

Set colLoggedEvents = objWMIService.ExecQuery _
("Select * from Win32_NTLogEvent Where Logfile = 'Application'")

For Each objEvent in colLoggedEvents
Wscript.Echo "Category: " & objEvent.Category
Wscript.Echo "Computer Name: " & objEvent.ComputerName
Wscript.Echo "Event Code: " & objEvent.EventCode
Wscript.Echo "Message: " & objEvent.Message
Wscript.Echo "Record Number: " & objEvent.RecordNumber
Wscript.Echo "Source Name: " & objEvent.SourceName
Wscript.Echo "Time Written: " & objEvent.TimeWritten
Wscript.Echo "Event Type: " & objEvent.Type
Wscript.Echo "User: " & objEvent.User
Next
end function

</script>
<p><a href="vbscript:eventlog">Check Event Logs</a> </p>
<hr>
<nobr Id=Results></nobr>
</body>
</html>

Re: cant read event logs with code that should work (I think!) by Michael

Michael
Mon Nov 01 11:54:03 CST 2004

multi-post

asked/answered in microsoft.public.scripting.wsh

--
Michael Harris
Microsoft.MVP.Scripting