Error checking example (VBScript)

This code can be found in Chapter 1 of Windows Server Cookbook

Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.

Find out how to download all of the VBScript code from this site.

' From the book "Windows Server Cookbook" by Robbie Allen
' ISBN: 0-596-00633-0

Option Explicit
On Error Resume Next
Dim objDomain
set objDomain = GetObject("LDAP://cn=users,dc=rallencorp,dc=com")
if Err.Number <> 0 then
	Wscript.Echo "An error occured getting the domain object: " & Err.Description
	Wscript.Quit
end if
Dim strDescr
strDescr = objDomain.Get("description")
if Err.Number <> 0 then
	Wscript.Echo "An error occured getting the description: " & Err.Description
	Wscript.Quit
end if
WScript.Echo "Description: " & strDescr
set objDomain = Nothing
set strDescr = Nothing

This code has been viewed 2475 times.

New from the creators of TechTasks.com: StatSheet.com