Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Netdom - Does not work the first time

Status
Not open for further replies.

Nitrous270

Technical User
Jul 27, 2002
67
0
0
US
I have this piece of my code that is calling netdom to remove the PC from a domain and put it into a workgroup.

The first time I execute the script it acts like it disjoins it from the domain. However, when I look at My Computer > Properties and the Network Identification tab the PC is still joined to the domain. Then if I run the script a second time and check the Network ID tab again it will be in the workgroup.

Any thoughts as to why the script does not do what its supposed to the first time but does the second time?

Thanks in advance



Call WshShell.Run("c:\sysprep\cmd.exe /c NETDOM REMOVE " & strPCName & _
" /Domain:" & strDomain & " /UserD:" & strDOMAIN_USER & " /PasswordD:" & _
strDOMAIN_PASSWORD, 0, True)


Also note that cmd.exe and netdom.exe are both located in c:\sysprep
 
What if you run the command directly at a command prompt?


Please tell me if I'm wrong I like to learn from my mistakes...
_____________________________________
Feed a man a fish and feed him for a day.
Teach a man to fish and feed him for a lifetime...
 
I anm going to guess that the first time the command is running on the domain controllers and the PC still thinks it is in the domain.

The second time you run it, the computer finds out from the domain that it doesn't have the domain access anymore.

The early bird gets the worm, but the second mouse gets the cheese.
 
It works fine the few times I have tested it from the command prompt. However I have another idea that came about yesterday when I was testing it...

If I run the script from a active directory account that has admin privlidges on the PC I have to run it 2 times.

If I run the script from a local account that has admin privlidges on the PC it has been flawless (so far).

Anybody know if that could cause the problem I'm having?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top