Computer Performance, Windows 2003, Exchange 2003, Logon Scripts

Code  80071392 - Object Already Exists

Troubleshooting Code 80071392- Object already exists

This error code, 80071392 occurs when the printer or network drive already exists.  A wild guess, you are running the script for the second time.  If so, you could consider error correcting code, see example 2 below.

Introduction to error Code 80071392

This is an easy error code to troubleshoot.  Code 80071392 usually occurs when you execute a VBScript.  Most likely the object has already been created, perhaps you are running the script for a second time.Code 80071392  Object already exists

The Symptoms you get 80071392

The script does not execute as you hoped, instead you get a WSH error message.  One possibility is that you are using a WSCRIPT and the object is already in Active Directory.

The Cause of Code 80071392

Active Directory already knows about the user, OU or computer that you are trying to create.  The problem is you are trying to create another object with the same name. Check the Line: number.  Char 1: often lies! it just means that the whole line will not execute.

The Solutions

1) Delete the object and start again. 

2) Add this line in the script: on error resume next.

  ‡

Example 1 - Script with 80071392 error

Note: The error is reported as Line 7, however it is actually the previous line where the problem was created.  objUser.SetInfo just causes the error to emerge.

'

'Script to Create a new Contact account in the BulkImport OU
'Script created by Guy Thomas
'Feel free to adapt names

Set objOU = GetObject("LDAP://OU=BulkImport, dc=cp, dc=com")
Set objUser = objOU.Create("contact", "cn=SalesMan")
objUser.SetInfo

Wscript.Echo "Success new Contact "

 

Example 2 - Adding Error Correcting Code to deal with Code Error 80071392

This script offers something a little different, not so much an error as example of error correcting code.

In this example I am creating a child OU. To handle the error I divided the OU path into strParent and strContainer.  Most of the error correcting takes place in the subroutine called GuyError().

 

 

' VBSCript to create a child OU (Organizational Unit)
' With Error Correcting code
' Author Guy Thomas http://computerperformance.co.uk/
' Version 2.4 - September 2005
' ----------------------------------------------------------'
Option Explicit
Dim objRoot, objDomain, objOU
Dim strContainer, strParent
err.number = vbEmpty

' Section to bind to YOUR Active Directory.
Set objRoot = GetObject("LDAP://rootDSE")
objDomain = objRoot.Get("defaultNamingContext")
Set objDomain = GetObject("LDAP://" & objDomain)

' Section to create the OU defined by strContainer
strParent ="OU=Accounts3"
strContainer ="OU=Child9," & strParent

On Error Resume next
Set objOU = objDomain.Create("organizationalUnit", strContainer )
objOU.Put "Description", "Guy's OU"
objOU.SetInfo

' Error Correcting Code
If Err.Number <> vbEmpty Then
    Call GuyError
Else
    WScript.Echo "New Child OU created = " & strContainer
End If
WScript.Quit(0)

' Error Correcting code to create Parent OU
Sub GuyError()
If Err.number = "-2147019886" then
     Wscript.Echo "Child OU already created"
     WScript.Quit(1)
Else
     Wscript.Echo "Error " & Err.number
     Set objOU = objDomain.Create("organizationalUnit", strParent )
     objOU.Put "Description", "Guy's Bulk Users OU"
     objOU.SetInfo
     Set objOU = objDomain.Create("organizationalUnit", strContainer )
     objOU.SetInfo
     WScript.Echo strParent & " Child and Parent OU Created "
End If
End Sub

 

Note 1:  Firstly, I researched the err.number for situations where the OU already existed, it turn out that the number was -2147019886.   You may be more familiar with this error as WSH Error: 80071392.

Example 3 - 80071392  Kindly Supplied by David Rocke

I discovered recently that Group.IsMember() returns FALSE when Group is "Domain Users" even though the user within that domain IS a member. This caused Error "". I have included a chunk of code where I have highlighted this and shown the use of "On Error Resume Next".

It should be noted that "On Error Goto ErrHandler" did not work, the error thrown by ADS seemed to circumvent it!

 

Sub AddUserToGroup(objUser As IADsUser, objGroup As IADsGroup)
  With objGroup
   'Retrieve information.
   .GetInfo
    If .IsMember(objUser.ADsPath) Then
      'Already a member so don't add.
    Else
      'ADS returns FALSE if the group in question is "Domain Users".
      'Use "On Error Resume Next" to avoid
      '&h80071392 "Automation Error - Object already exists"
      On Error Resume Next
         .Add objUser.ADsPath
      On Error GoTo 0
   .SetInfo
  End If
 End With 'objGroup
 Set objGroup = Nothing
End Sub

 

Guy Recommends: WMI Monitor and Its Free!Solarwinds WMI Monitor

Windows Management Instrumentation (WMI) is one of the hidden treasures of Microsoft operating systems.  Fortunately, Solarwinds have created the WMI Monitor so that you can examine these gems of performance information for free.  Take the guess work out of which WMI counters to use for applications like Microsoft Active Directory, SQL or Exchange Server.

Download your free copy of WMI Monitor


Computer Training Software - Recommended Training VideosGuy Thomas recommends Computer Training Software

Their topics and material are ideal for getting you started with VBScript.  The videos are easy to follow and you can control the pace.  Try their free demo material and then see if you want to buy the full package. See more about VB Script Training CD.


Do you need extra help?

For interpreting the WSH messages check Diagnose 800 errors.

For general advice try my 7 Troubleshooting techniques

Give something back?

Would you like to help others?  If you have a good example of this error, then please email me, I will publish it with a credit to you:

 


Download my Logon Script eBook for only $6.25

Logon ScriptThe extra features you get in your eBook include, more pages full of detailed examples.  Also, ten 'how to...' sections, with screen shots showing which menus to use.  Go for Guy's eBook - and get a printable version with copy enabled and no expiry date.

  Jumbo Script 7 Package

 *


Google

Web  This website

Guy Recommends: SolarWinds Engineer's Toolset v10Engineer's Toolset v10

The Engineer's Toolset v10 provides a comprehensive console of utilities for troubleshooting computer problems.

There are so many good gadgets, it's like having free rein of a sweetshop. Thankfully the utilities are displayed logically: monitoring, discovery, diagnostic, and Cisco tools.  Download your copy of the Engineer's Toolset v 10

 

Home Copyright © 1999-2010 Computer Performance LTD All rights reserved.

Please report a broken link, or an error.