Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old October 21st, 2004, 01:06 AM
greg orr greg orr is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 1 greg orr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Angry Frustrated

I have spent ages trying to get this to work but It has got the best of me can anybody point out the obvious please.
My plan is to have an email sent to me via smartmail with the results.

Set objArgs = WScript.Arguments
Const ForReading = 1
Set objDictionary = CreateObject("Scripting.Dictionary")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("serverlist.txt", ForReading)
Set dtmStartDate = CreateObject("WbemScripting.SWbemDateTime")
Set dtmEndDate = CreateObject("WbemScripting.SWbemDateTime")
DateToCheck = Date - 1
dtmEndDate.SetVarDate Date, True
dtmStartDate.SetVarDate DateToCheck, True
i = 0

Do While objTextFile.AtEndOfStream <> True
strNextLine = objTextFile.Readline
objDictionary.Add i, strNextLine
i = i + 1
Loop

For Each objitem in objDictionary
Set colServices = GetObject("winmgmts://" & objDictionary.Item(objItem) _
& "").ExecQuery("Select * from Win32_NTLogEvent Where Logfile = 'Application' and " _
&
"EventCode = '208' and " _
&
TimeWritten >= '" _
& dtmStartDate & "' and TimeWritten < '" & dtmEndDate & "'")
For Each objEvent in colServices
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

Reply With Quote
  #2  
Old October 23rd, 2004, 01:52 AM
Leslie's Avatar
Leslie Leslie is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Honolulu
Posts: 184 Leslie User rank is Corporal (100 - 500 Reputation Level)Leslie User rank is Corporal (100 - 500 Reputation Level)Leslie User rank is Corporal (100 - 500 Reputation Level)Leslie User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 20 h 29 m 2 sec
Reputation Power: 10
I noticed you use set objArgs but I don't see where you ever use it?

Anyway, you have two For Each statements and ONE Next

To make your select more readable you can first put the SELECT statement in a varialbe and then use the variable in the Set statement. It's too hard to keep track of all of your line continuations, easy to miss a quote somewhere and you won't know it if you are simply running this as a script file.

stmnt = "Select * from Win32_NTLogEvent Where Logfile = 'Application' and EventCode = '208' and TimeWritten >= '" & dtmStartDate & "' and TimeWritten < '" & dtmEndDate & "'"

Set colServices = GetObject("winmgmts://" & objDictionary.Item(objItem)).ExecQuery(stmnt)

You can use MS Access as a debug tool:
Open database module, create private sub, paste the above code into it (between the "Privat Sub mysub()" and "End Sub", then goto tools, references and checkmark "Microsoft Scripting Runtime"

You will have to make some slight modifications (comment out straight script like Date - 1 and replace with a dateadd("d",1,date), but it only takes a few minutes to provide the alternative syntax to the point where Access will tell you that you are mising something like a Next statement. Plus you can put a break point in there and step through your code.

You can use SQL Server DTS to test scripts:
Create a new Data Transformation Package. Click on ActiveX Script. Open it and past your code in. You cannot debug with breakpoints but it does understand straight script like Date-1. YOu can systematically comment out blocks of code and place strategic mesage boxes to help you debug.

msgbox = strNextLine

either way
You can force values into variables such as

strNextLine = some deliberate value
i=0
objDictionary.Add i, strNextLine
i=i+1
stNextLine = some other deliberte value
objDictionary.Add i

Is the objDictinariy getting updated??

msgbox objDictionary(some property)

If you don't know what properties are avaialbe, place a breakpoint in Access on the first line, step the code until you have opened the object - comment out erroring code if you need to as long as you can still get the object to open (or just drag your yellow highlight to the step you want) - then open the Locals window. what do you see? your object is on the list with current values. You can check the state of everything at any moment in time. You can browse properties. Well worth the hassle of converting it back from VBA to script if you ask me! Or just leave your script in Access and let it run the finished script as VBA using the microsfot scripting library described above.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingCode Bank > Frustrated


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 8 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek