UnjoinDomainOrWorkgroup Windows 2000


D

DMc2007

Hi

Does the Win32_ComputerSystem method UnjoinDomainOrWorkgroup support Windows
2000 Clients, as I am getting am error on the following:

Const NETSETUP_ACCT_DELETE = 2 'Disables computer account in domain.
strPassword = "SW2009Feb10792-d"
strUser = "SWCAMW"

Dim intreturn
Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName

Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\"
& _
strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & strComputer &
"'")
strDomain = objComputer.Domain
intReturn = objComputer.UnjoinDomainOrWorkgroup _
(strPassword, strDomain & "\" & strUser, NETSETUP_ACCT_DELETE)

Basically i am trying to remove a Windows 2000 Workstation from a Domain.

Regards

D
 
Ad

Advertisements

P

Paul Bergson [MVP-DS]

R

Richard Mueller [MVP]

DMc2007 said:
Hi

Does the Win32_ComputerSystem method UnjoinDomainOrWorkgroup support
Windows 2000 Clients, as I am getting am error on the following:

Const NETSETUP_ACCT_DELETE = 2 'Disables computer account in domain.
strPassword = "SW2009Feb10792-d"
strUser = "SWCAMW"

Dim intreturn
Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName

Set objComputer =
GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & _
strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & strComputer &
"'")
strDomain = objComputer.Domain
intReturn = objComputer.UnjoinDomainOrWorkgroup _
(strPassword, strDomain & "\" & strUser, NETSETUP_ACCT_DELETE)

Basically i am trying to remove a Windows 2000 Workstation from a Domain.

Regards

D

Per this link it should work on Windows 2000 clients:

http://www.microsoft.com/technet/scriptcenter/scripts/ad/computer/cptrvb19.mspx

If you get an error, what is the error message and on which line is it
raised?
 
D

DMc2007

Using on a Windows 2000 SP4 Domain workstation, on a Windows 2003 Domain.

Code is below:

Const NETSETUP_ACCT_DELETE = 2 'Disables computer account in domain.
strPassword = "SW2009Feb10792-d"
strUser = "SWCAMW"

Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName

Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" &
_
strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & strComputer &
"'")
strDomain = objComputer.Domain
intReturn = objComputer.UnjoinDomainOrWorkgroup _
(strPassword, strDomain & "\" & strUser, NETSETUP_ACCT_DELETE)

Error message is as follows:

Script: C:\Temp\DeleteFromDomain.vbs
Line: 11
Char: 1
Error: Object doesn't support this property or method:
'objComputer.UnjoinDomainOrWorkGroup'
Code: 800A01B6
Source: Microsoft VBScript runtime error.

Kind Regards

D
 
Ad

Advertisements

R

Richard Mueller [MVP]

I've never used the UnjoinDomainOrWorkgroup method, but I just looked at my
script that uses the JoinDomainOrWorkgroup method. I have this comment based
on research I did some time ago:

' The computer must have XP or above.
' The AD must be W2k3 or above.
' See c:\Windows\debug\NetSetup.log for details.

I would say the link I gave is incorrect. The client must be XP or above
(unless someone knows how to upgrade WMI to support the method).

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--

DMc2007 said:
Using on a Windows 2000 SP4 Domain workstation, on a Windows 2003 Domain.

Code is below:

Const NETSETUP_ACCT_DELETE = 2 'Disables computer account in domain.
strPassword = "SW2009Feb10792-d"
strUser = "SWCAMW"

Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName

Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\"
& _
strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & strComputer &
"'")
strDomain = objComputer.Domain
intReturn = objComputer.UnjoinDomainOrWorkgroup _
(strPassword, strDomain & "\" & strUser, NETSETUP_ACCT_DELETE)

Error message is as follows:

Script: C:\Temp\DeleteFromDomain.vbs
Line: 11
Char: 1
Error: Object doesn't support this property or method:
'objComputer.UnjoinDomainOrWorkGroup'
Code: 800A01B6
Source: Microsoft VBScript runtime error.

Kind Regards

D
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top