Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
Knowing that a remotely executing script has encountered an error is important. However, once you know the error has occurred, you next need to determine the cause and correct the problem. If an error occurs in a remotely executing script, the WshRemoteError object can be accessed as a property of the WshRemote object. The WshRemoteError object includes a number of properties that describe the error that occurred and can help you troubleshoot the problem. These properties are shown in Table 3.25.
Table 3.25 Properties of the WshRemoteError Object
Property | Description |
---|---|
Character | Returns the character position in the line where the error occurred. For example, in this simple script, the semicolon is an invalid character. Because the semicolon is the 14th character in the line, the Character property is 14: |
Description | Brief description of the error. |
Line | Line number of the script in which the error occurred. |
Number | Error code associated with the error. |
Source | Identifies the COM object that reported the error. |
SourceText | Contains the line of code that generated the error. The SourceText cannot always be retrieved; in that case, an empty string will be returned. |
The script in Listing 3.44 includes a subroutine that handles the Error event. Unlike the script in Listing 3.43, which simply displayed a message indicating that an error occurred, this script uses the WshRemote object Error property to retrieve an instance of the WshRemoteError object. The script then displays all of the properties of the WshRemoteError object, providing you with a great deal of information that is useful for troubleshooting the problem.
Listing 3.44 Examining Errors Produced by a Script Running Remotely
|
|
Send us your feedback | « Previous | Next » |