Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Reporting Errors

Reply
 
Old 09-05-2008   #1 (permalink)
OldDog


 
 

Reporting Errors

Hi,

I found this snippet on another group. Can someone tell me where this
will write the errors to?

Sub ReportErrors(ErrText)
If err.number <> 0 then
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.LogEvent 1, ErrText & " Error code " & err.number & " (" &
err.description & ")"
Err.clear
End If
End Sub


The systems event log? application?


OldDog

My System SpecsSystem Spec
Old 09-05-2008   #2 (permalink)
Pegasus \(MVP\)


 
 

Re: Reporting Errors


"OldDog" <michael.r.felkins@xxxxxx> wrote in message
news:58ccb240-3cb1-4e4d-9548-f768d4ee50df@xxxxxx
Quote:

> Hi,
>
> I found this snippet on another group. Can someone tell me where this
> will write the errors to?
>
> Sub ReportErrors(ErrText)
> If err.number <> 0 then
> Set WshShell = WScript.CreateObject("WScript.Shell")
> WshShell.LogEvent 1, ErrText & " Error code " & err.number & " (" &
> err.description & ")"
> Err.clear
> End If
> End Sub
>
>
> The systems event log? application?
>
>
> OldDog
Best to download the file "script56.chm" from the Microsoft site and use its
search function to find the string "LogEvent". It will tell you exactly
where the message goes (and will probably answer lots of future questions
too!).


My System SpecsSystem Spec
Old 09-05-2008   #3 (permalink)
OldDog


 
 

Re: Reporting Errors

On Sep 5, 12:30*pm, "Pegasus \(MVP\)" <I....@xxxxxx> wrote:
Quote:

> "OldDog" <michael.r.felk...@xxxxxx> wrote in message
>
> news:58ccb240-3cb1-4e4d-9548-f768d4ee50df@xxxxxx
>
>
>
>
>
Quote:

> > Hi,
>
Quote:

> > I found this snippet on another group. Can someone tell me where this
> > will write the errors to?
>
Quote:

> > Sub ReportErrors(ErrText)
> > If err.number <> 0 then
> > *Set WshShell = WScript.CreateObject("WScript.Shell")
> > *WshShell.LogEvent 1, ErrText & " Error code " & err.number & " (" &
> > err.description & ")"
> > *Err.clear
> > End If
> > End Sub
>
Quote:

> > The systems event log? application?
>
Quote:

> > OldDog
>
> Best to download the file "script56.chm" from the Microsoft site and use its
> search function to find the string "LogEvent". It will tell you exactly
> where the message goes (and will probably answer lots of future questions
> too!).- Hide quoted text -
>
> - Show quoted text -
I am sure that would be a good source, however chm files do not open
on my WindowsXP Pro SP 3 desktop.
Well, they open, but the right hand screen reports an error.
"Navigation to the Web Page was cancelled."

OldDog
My System SpecsSystem Spec
Old 09-05-2008   #4 (permalink)
Pegasus \(MVP\)


 
 

Re: Reporting Errors


"OldDog" <michael.r.felkins@xxxxxx> wrote in message
news:299fc20b-3822-4097-a020-be79dd297501@xxxxxx
On Sep 5, 12:30 pm, "Pegasus \(MVP\)" <I....@xxxxxx> wrote:
Quote:

> "OldDog" <michael.r.felk...@xxxxxx> wrote in message
>
> news:58ccb240-3cb1-4e4d-9548-f768d4ee50df@xxxxxx
>
>
>
>
>
Quote:

> > Hi,
>
Quote:

> > I found this snippet on another group. Can someone tell me where this
> > will write the errors to?
>
Quote:

> > Sub ReportErrors(ErrText)
> > If err.number <> 0 then
> > Set WshShell = WScript.CreateObject("WScript.Shell")
> > WshShell.LogEvent 1, ErrText & " Error code " & err.number & " (" &
> > err.description & ")"
> > Err.clear
> > End If
> > End Sub
>
Quote:

> > The systems event log? application?
>
Quote:

> > OldDog
>
> Best to download the file "script56.chm" from the Microsoft site and use
> its
> search function to find the string "LogEvent". It will tell you exactly
> where the message goes (and will probably answer lots of future questions
> too!).- Hide quoted text -
>
> - Show quoted text -
I am sure that would be a good source, however chm files do not open
on my WindowsXP Pro SP 3 desktop.
Well, they open, but the right hand screen reports an error.
"Navigation to the Web Page was cancelled."

OldDog

===================

Try opening it with this command: hh c:\script56.chm, then try to fix your
Windows help facility. In the meantime here is what the help file says:

Log Event Method

Adds an event entry to a log file.

object.LogEvent(intType, strMessage [,strTarget])

Arguments
object
WshShell object.

intType
Integer value representing the event type.

strMessage
String value containing the log entry text.

strTarget
Optional. String value indicating the name of the computer system where the
event log is stored (the default is the local computer system). Applies to
Windows NT/2000 only.

Remarks
The LogEvent method returns a Boolean value (true if the event is logged
successfully, otherwise false). In Windows NT/2000, events are logged in the
Windows NT Event Log. In Windows 9x/Me, events are logged in WSH.log
(located in the Windows directory). There are six event types.

Type Value
0 SUCCESS

1 ERROR

2 WARNING

4 INFORMATION

8 AUDIT_SUCCESS

16 AUDIT_FAILURE


Example
The following code logs SUCCESS or ERROR depending on the outcome of the
function runLoginScript().

Visual Basic Script Copy Code
Set WshShell = WScript.CreateObject("WScript.Shell")
rc = runLoginScript() 'Returns true if logon succeeds.

if rc then
WshShell.LogEvent 0, "Logon Script Completed Successfully"
else
WshShell.LogEvent 1, "Logon Script failed"
end if

JScript Copy Code
var WshShell = WScript.CreateObject("WScript.Shell");
var rc = runLoginScript();

if (rc)
WshShell.LogEvent(0, "Logon Script Completed Successfully");
else
WshShell.LogEvent(1, "Logon Script failed");

Applies To:
WshShell Object




My System SpecsSystem Spec
Old 09-05-2008   #5 (permalink)
OldDog


 
 

Re: Reporting Errors

On Sep 5, 1:30*pm, "Pegasus \(MVP\)" <I....@xxxxxx> wrote:
Quote:

> "OldDog" <michael.r.felk...@xxxxxx> wrote in message
>
> news:299fc20b-3822-4097-a020-be79dd297501@xxxxxx
> On Sep 5, 12:30 pm, "Pegasus \(MVP\)" <I....@xxxxxx> wrote:
>
>
>
>
>
Quote:

> > "OldDog" <michael.r.felk...@xxxxxx> wrote in message
>
Quote:

> >news:58ccb240-3cb1-4e4d-9548-f768d4ee50df@xxxxxx
>
Quote:
Quote:

> > > Hi,
>
Quote:
Quote:

> > > I found this snippet on another group. Can someone tell me where this
> > > will write the errors to?
>
Quote:
Quote:

> > > Sub ReportErrors(ErrText)
> > > If err.number <> 0 then
> > > Set WshShell = WScript.CreateObject("WScript.Shell")
> > > WshShell.LogEvent 1, ErrText & " Error code " & err.number & " (" &
> > > err.description & ")"
> > > Err.clear
> > > End If
> > > End Sub
>
Quote:
Quote:

> > > The systems event log? application?
>
Quote:
Quote:

> > > OldDog
>
Quote:

> > Best to download the file "script56.chm" from the Microsoft site and use
> > its
> > search function to find the string "LogEvent". It will tell you exactly
> > where the message goes (and will probably answer lots of future questions
> > too!).- Hide quoted text -
>
Quote:

> > - Show quoted text -
>
> I am sure that would be a good source, however chm files do not open
> on my WindowsXP Pro SP 3 desktop.
> Well, they open, but the right hand screen reports an error.
> "Navigation to the Web Page was cancelled."
>
> OldDog
>
> ===================
>
> Try opening it with this command: hh c:\script56.chm, then try to fix your
> Windows help facility. In the meantime here is what the help file says:
>
> Log Event Method
>
> Adds an event entry to a log file.
>
> object.LogEvent(intType, strMessage [,strTarget])
>
> Arguments
> object
> WshShell object.
>
> intType
> Integer value representing the event type.
>
> strMessage
> String value containing the log entry text.
>
> strTarget
> Optional. String value indicating the name of the computer system where the
> event log is stored (the default is the local computer system). Applies to
> Windows NT/2000 only.
>
> Remarks
> The LogEvent method returns a Boolean value (true if the event is logged
> successfully, otherwise false). In Windows NT/2000, events are logged in the
> Windows NT Event Log. In Windows 9x/Me, events are logged in WSH.log
> (located in the Windows directory). There are six event types.
>
> Type *Value
> 0 *SUCCESS
>
> 1 *ERROR
>
> 2 *WARNING
>
> 4 *INFORMATION
>
> 8 *AUDIT_SUCCESS
>
> 16 *AUDIT_FAILURE
>
> Example
> The following code logs SUCCESS or ERROR depending on the outcome of the
> function runLoginScript().
>
> Visual Basic Script *Copy Code
> Set WshShell = WScript.CreateObject("WScript.Shell")
> rc = runLoginScript() * * *'Returns true if logon succeeds.
>
> if rc then
> * *WshShell.LogEvent 0, "Logon Script Completed Successfully"
> else
> * *WshShell.LogEvent 1, "Logon Script failed"
> end if
>
> JScript *Copy Code
> var WshShell = WScript.CreateObject("WScript.Shell");
> var rc = runLoginScript();
>
> if (rc)
> * *WshShell.LogEvent(0, "Logon Script Completed Successfully");
> else
> * *WshShell.LogEvent(1, "Logon Script failed");
>
> Applies To:
> WshShell Object- Hide quoted text -
>
> - Show quoted text -

Thanks,

I have tried every fix in the book for my chm files, to no avail.

Anyway, I am still unclear in which of the log files the event will be
written to:
Application
System
Security

And I don't see a paramiter to set that.

OldDog
My System SpecsSystem Spec
Old 09-05-2008   #6 (permalink)
James Whitlow


 
 

Re: Reporting Errors

"OldDog" <michael.r.felkins@xxxxxx> wrote in message
news:58ccb240-3cb1-4e4d-9548-f768d4ee50df@xxxxxx
Quote:

> Hi,
>
> I found this snippet on another group. Can someone tell me where this
> will write the errors to?
>
> Sub ReportErrors(ErrText)
> If err.number <> 0 then
> Set WshShell = WScript.CreateObject("WScript.Shell")
> WshShell.LogEvent 1, ErrText & " Error code " & err.number & " (" &
> err.description & ")"
> Err.clear
> End If
> End Sub
>
>
> The systems event log? application?
It should get written to the Application Event Log. To the best of my
knowledge, VBScript can only write to the Application Event Log and not any
of the others (someone please correct me if I am wrong).

From script56.chm:
-------------------------
*LogEvent Method*

Adds an event entry to a log file.

object.LogEvent(intType, strMessage [,strTarget])

Arguments
object (WshShell object)

intType
Integer value representing the event type.

strMessage
String value containing the log entry text.

strTarget
Optional. String value indicating the name of the computer system
where the event log is stored (the default is the local computer
system). Applies to Windows NT/2000 only.

Remarks
The LogEvent method returns a Boolean value (true if the event is
logged successfully, otherwise false). In Windows NT/2000, events
are logged in the Windows NT Event Log. In Windows 9x/Me, events
are logged in WSH.log (located in the Windows directory). There
are six event types.

Type 0 (SUCCESS)
Type 1 (ERROR
Type 2 (WARNING
Type 4 (INFORMATION)
Type 8 (AUDIT_SUCCESS)
Type 16 (AUDIT_FAILURE)


My System SpecsSystem Spec
Old 09-05-2008   #7 (permalink)
Pegasus \(MVP\)


 
 

Re: Reporting Errors


"OldDog" <michael.r.felkins@xxxxxx> wrote in message
news:3ea2f4e4-a4b3-4ccc-8e4f-036cdb232bce@xxxxxx
On Sep 5, 1:30 pm, "Pegasus \(MVP\)" <I....@xxxxxx> wrote:
Quote:

> "OldDog" <michael.r.felk...@xxxxxx> wrote in message
>
> news:299fc20b-3822-4097-a020-be79dd297501@xxxxxx
> On Sep 5, 12:30 pm, "Pegasus \(MVP\)" <I....@xxxxxx> wrote:
>
>
>
>
>
Quote:

> > "OldDog" <michael.r.felk...@xxxxxx> wrote in message
>
Quote:

> >news:58ccb240-3cb1-4e4d-9548-f768d4ee50df@xxxxxx
>
Quote:
Quote:

> > > Hi,
>
Quote:
Quote:

> > > I found this snippet on another group. Can someone tell me where this
> > > will write the errors to?
>
Quote:
Quote:

> > > Sub ReportErrors(ErrText)
> > > If err.number <> 0 then
> > > Set WshShell = WScript.CreateObject("WScript.Shell")
> > > WshShell.LogEvent 1, ErrText & " Error code " & err.number & " (" &
> > > err.description & ")"
> > > Err.clear
> > > End If
> > > End Sub
>
Quote:
Quote:

> > > The systems event log? application?
>
Quote:
Quote:

> > > OldDog
>
Quote:

> > Best to download the file "script56.chm" from the Microsoft site and use
> > its
> > search function to find the string "LogEvent". It will tell you exactly
> > where the message goes (and will probably answer lots of future
> > questions
> > too!).- Hide quoted text -
>
Quote:

> > - Show quoted text -
>
> I am sure that would be a good source, however chm files do not open
> on my WindowsXP Pro SP 3 desktop.
> Well, they open, but the right hand screen reports an error.
> "Navigation to the Web Page was cancelled."
>
> OldDog
>
> ===================
>
> Try opening it with this command: hh c:\script56.chm, then try to fix your
> Windows help facility. In the meantime here is what the help file says:
>
> Log Event Method
>
> Adds an event entry to a log file.
>
> object.LogEvent(intType, strMessage [,strTarget])
>
> Arguments
> object
> WshShell object.
>
> intType
> Integer value representing the event type.
>
> strMessage
> String value containing the log entry text.
>
> strTarget
> Optional. String value indicating the name of the computer system where
> the
> event log is stored (the default is the local computer system). Applies to
> Windows NT/2000 only.
>
> Remarks
> The LogEvent method returns a Boolean value (true if the event is logged
> successfully, otherwise false). In Windows NT/2000, events are logged in
> the
> Windows NT Event Log. In Windows 9x/Me, events are logged in WSH.log
> (located in the Windows directory). There are six event types.
>
> Type Value
> 0 SUCCESS
>
> 1 ERROR
>
> 2 WARNING
>
> 4 INFORMATION
>
> 8 AUDIT_SUCCESS
>
> 16 AUDIT_FAILURE
>
> Example
> The following code logs SUCCESS or ERROR depending on the outcome of the
> function runLoginScript().
>
> Visual Basic Script Copy Code
> Set WshShell = WScript.CreateObject("WScript.Shell")
> rc = runLoginScript() 'Returns true if logon succeeds.
>
> if rc then
> WshShell.LogEvent 0, "Logon Script Completed Successfully"
> else
> WshShell.LogEvent 1, "Logon Script failed"
> end if
>
> JScript Copy Code
> var WshShell = WScript.CreateObject("WScript.Shell");
> var rc = runLoginScript();
>
> if (rc)
> WshShell.LogEvent(0, "Logon Script Completed Successfully");
> else
> WshShell.LogEvent(1, "Logon Script failed");
>
> Applies To:
> WshShell Object- Hide quoted text -
>
> - Show quoted text -

Thanks,

I have tried every fix in the book for my chm files, to no avail.

Anyway, I am still unclear in which of the log files the event will be
written to:
Application
System
Security

And I don't see a paramiter to set that.

OldDog
==============

See James' reply for the destination of the event item. You could also
create an event with your script, then check where it ends up!

You may want to add a few more chapters to your book about fixing broken
help files:
http://support.microsoft.com/kb/896358
http://support.microsoft.com/kb/896054

http://www.dougknox.com/xp/utils/fix...ws_xp_help.htm
http://www.kellys-korner-xp.com/top10faqs.htm
Or re-install Help:
Open the folder c:\windows\inf and right-click the PCHealth.inf file, then
choose "Install". If you have a Service Pack installed, select
c:\windows\i386\ServicePackFiles\PCHealth.inf instead.


My System SpecsSystem Spec
Old 09-05-2008   #8 (permalink)
OldDog


 
 

Re: Reporting Errors

On Sep 5, 2:32*pm, "James Whitlow" <jwhitlow.60372...@xxxxxx>
wrote:
Quote:

> "OldDog" <michael.r.felk...@xxxxxx> wrote in message
>
> news:58ccb240-3cb1-4e4d-9548-f768d4ee50df@xxxxxx
>
>
>
>
>
Quote:

> > Hi,
>
Quote:

> > I found this snippet on another group. Can someone tell me where this
> > will write the errors to?
>
Quote:

> > Sub ReportErrors(ErrText)
> > If err.number <> 0 then
> > *Set WshShell = WScript.CreateObject("WScript.Shell")
> > *WshShell.LogEvent 1, ErrText & " Error code " & err.number & " (" &
> > err.description & ")"
> > *Err.clear
> > End If
> > End Sub
>
Quote:

> > The systems event log? application?
>
> * * It should get written to the Application Event Log. To the best of my
> knowledge, VBScript can only write to the Application Event Log and not any
> of the others (someone please correct me if I am wrong).
>
> From script56.chm:
> -------------------------
> *LogEvent Method*
>
> Adds an event entry to a log file.
>
> object.LogEvent(intType, strMessage [,strTarget])
>
> Arguments
> * object (WshShell object)
>
> intType
> * Integer value representing the event type.
>
> strMessage
> * String value containing the log entry text.
>
> strTarget
> * Optional. String value indicating the name of the computer system
> * where the event log is stored (the default is the local computer
> * system). Applies to Windows NT/2000 only.
>
> Remarks
> * The LogEvent method returns a Boolean value (true if the event is
> * logged successfully, otherwise false). In Windows NT/2000, events
> * are logged in the Windows NT Event Log. In Windows 9x/Me, events
> * are logged in WSH.log (located in the Windows directory). There
> * are six event types.
>
> * * Type 0 (SUCCESS)
> * * Type 1 (ERROR
> * * Type 2 (WARNING
> * * Type 4 (INFORMATION)
> * * Type 8 (AUDIT_SUCCESS)
> * * Type 16 (AUDIT_FAILURE)- Hide quoted text -
>
> - Show quoted text -
Yep, Application log. Thanks and why don't they just come out and say
that??
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Error Reporting not Reporting Back Vista General
Reporting Notification 3010 or 3014 errors Virtual Server
Errors, errors and more errors - I have Issues! Vista performance & maintenance
explorer errors, program errors, no task manager Vista performance & maintenance
Useful function when reporting errors PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46