[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

join a computer to the domain with a script

Posted on 2009-06-28
18
Medium Priority
?
383 Views
Last Modified: 2012-05-07
I wonder if someone has used a script to join a computer to the domain.
I used a script in an environment and worked fine, the same script tried it in a different environment and it never worked.
So if someone has a similar script that can join a computer to the domain. please post it here.

Thanks.
0
Comment
Question by:jskfan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 12
  • 4
  • 2
18 Comments
 
LVL 23

Expert Comment

by:ComputerTechie
ID: 24733245
0
 

Author Comment

by:jskfan
ID: 24735310
My environment is windows 2003 servers/windowsXP/Vista.
0
 

Author Comment

by:jskfan
ID: 24773174
any updates????
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 23

Expert Comment

by:ComputerTechie
ID: 24773326
0
 

Author Comment

by:jskfan
ID: 24784531
I will try it later.......it looks like I have the same script but it's not working...
0
 

Author Comment

by:jskfan
ID: 24785829
where do you run this script from?
0
 
LVL 23

Accepted Solution

by:
ComputerTechie earned 1500 total points
ID: 24785995
you can run it from server. make sure to change as directed in the post and in lines 37-39

CT
0
 

Author Comment

by:jskfan
ID: 24802754
I did run it from the server that I needed to join to the domain. it prompt me for computer name, I typed the computer name and it said computer renamed successfully, then it gave me a message error 0 exiting script, then it rebooted the computer. I logged in and the computer is still in workgroup, it didn't get joined to the domain.
0
 

Author Comment

by:jskfan
ID: 24802773
this is exactely the error I got

<<<Join Domain failed. error=0 Exiting script>>
0
 

Author Comment

by:jskfan
ID: 24804226
This script below does the right job, but only when I run it locally in the machine I want to join to the domain.
I tried to run it remotelt using PSexec but it doesn't run the script::
PSexec \\remotecomputername cscript.exe C:\file.vbs
it says something about the script exited with error code: 0
if I use PSexec \\remotecomputername wscript.exe C:\file.vbs
the scripts hangs on forever

Here is the script that runs good when locally executed.




wscript.sleep 60
Const JOIN_DOMAIN = 1
Const ACCT_CREATE = 2
Const ACCT_DELETE = 4
Const WIN9X_UPGRADE = 16
Const DOMAIN_JOIN_IF_JOINED = 32
Const JOIN_UNSECURE = 64
Const MACHINE_PASSWORD_PASSED = 128
Const DEFERRED_SPN_SET = 256
Const INSTALL_INVOCATION = 262144
 
strDomain = "mydomain.com"
strPassword = "domainpassword"
strUser = "Administrator"
 
Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName
wscript.echo strcomputer
Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & _
    strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & _
        strComputer & "'")
 
ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
    strPassword, strDomain & "\" & strUser, NULL, _
        JOIN_DOMAIN + ACCT_CREATE)
Dim oShell
 
Set oShell = CreateObject("Wscript.Shell")
sReturn = oShell.Run("%comspec% /c shutdown -r -t 0 -f")
0
 
LVL 23

Expert Comment

by:ComputerTechie
ID: 24804328
canyou put the script on a network share and run it

here is another post from another person asking the same thisng.

http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_23830424.html

CT
0
 

Author Comment

by:jskfan
ID: 24804410
how do you run it from the share using psexec?
0
 

Author Comment

by:jskfan
ID: 24804436
I even create a GPO logon script and it didn't work.
0
 

Author Comment

by:jskfan
ID: 24804572
Wow.......PSexec is working fine now
PSexec \\RemoteComputerName cscript -i  -d cscript.exe C:\file.vbs

file.vbd is the script I pasted above in the thread.

it joined the computer to the domain and rebooted it.

0
 

Author Comment

by:jskfan
ID: 24804622
I wonder what the switches -i and -d  did to help.
I looked the psexec help and could not understand it
0
 
LVL 47

Expert Comment

by:Donald Stewart
ID: 24804675
have you tried the script here?
 
http://techtasks.com/code/viewbookcode/1642 
0
 
LVL 47

Expert Comment

by:Donald Stewart
ID: 24804683
0
 

Author Comment

by:jskfan
ID: 24805310
dstewartjr:

why world I try it.the one I posted worked.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question