The most important command is to change the domain the computer is logged into. Any Ideas?
Main Topics
Browse All TopicsGreetings Experts,
I am new to the scripting world, and I would like to know if it is possiable to make a script or set of batch files that will do the following:
Login to the computer
Change the domain from old to new
Reboot
Login as administrator
Make the user of the machine a local admin
Login as the user (let windows create a new profile)
Logout then Login in as admin Rename the new profile directory "name.junk"
Rename the original directory "name.new profile dir".
Logout
Login as the new user
I know most of this is possiable but I am wondering if someone can help me with the coding with an example or a link to help me on my way.
Thanks,
Jason
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Have a look here:
http://www.rallenhome.com/
Tac
After reviewing the above link I found a script that will be usefull but I can not get it to work.
++++++++++++++++++++++++++
+++++++++++++++++++START OF SCRIPT FILE+++++++++++++++++++
++++++++++++++++++++++++++
' This VBScript code joins a computer to a domain.
' --------------------------
' From the book "Active Directory Cookbook" by Robbie Allen
' Publisher: O'Reilly and Associates
' ISBN: 0-596-00466-4
' Book web site: http://rallenhome.com/book
' --------------------------
' ------ SCRIPT CONFIGURATION ------
strComputer = "<ComputerName>" ' e.g. joe-xp
strDomain = "<DomainName>" ' e.g. rallencorp.com
strDomainUser = "<DomainUserUPN>" ' e.g. administrator@rallencorp.c
strDomainPasswd = "<DomainUserPasswd>"
strLocalUser = "<ComputerAdminUser>" ' e.g. administrator
strLocalPasswd = "<ComputerUserPasswd>"
' ------ END CONFIGURATION ---------
'########################
' Constants
'########################
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
'#########################
' Connect to Computer
'#########################
set objWMILocator = CreateObject("WbemScriptin
objWMILocator.Security_.Au
set objWMIComputer = objWMILocator.ConnectServe
"root\cimv2", _
strLocalUser, _
strLocalPasswd)
set objWMIComputerSystem = objWMIComputer.Get( _
"Win32_ComputerSystem.Name
strComputer & "'")
'#########################
' Join Computer
'#########################
rc = objWMIComputerSystem.JoinD
strDomainPasswd, _
strDomainUser, _
vbNullString, _
JOIN_DOMAIN)
if rc <> 0 then
WScript.Echo "Join failed with error: " & rc
else
WScript.Echo "Successfully joined " & strComputer & " to " & strDomain
end if
++++++++++++++++++++++++++
++++++++++++++++++++END OF SCRIPT FILE++++++++++++++++++++
++++++++++++++++++++++++++
When I run this on the machine I would like to I get an error on line 37,char 1 which i believe is:
set objWMIComputer = objWMILocator.ConnectServe
"root\cimv2", _
strLocalUser, _
strLocalPasswd)
User credentials cannot be used for local connections
code: 80041064
Source: SWbemLocator
Please help.
In this section of the vbscript code :
' ------ SCRIPT CONFIGURATION ------
strComputer = "<ComputerName>" ' e.g. joe-xp
strDomain = "<DomainName>" ' e.g. rallencorp.com
strDomainUser = "<DomainUserUPN>" ' e.g. administrator@rallencorp.c
strDomainPasswd = "<DomainUserPasswd>"
strLocalUser = "<ComputerAdminUser>" ' e.g. administrator
strLocalPasswd = "<ComputerUserPasswd>"
' ------ END CONFIGURATION ---------
Are you replacing the <ComputerName> <DomainName> etc etc with your computername, domain name etc ?
try using impersonation...
not sure how to set it up for your case but here is an example from another...
Set objComputer = GetObject("winmgmts:{imper
strComputer & "\root\cimv2:Win32_Compute
strComputer & "'")
also..
the example in this link is using vbscript to get the job done but you should be able to use it to get your answer. If I get the time I'll try it.
http://msdn.microsoft.com/
Business Accounts
Answer for Membership
by: gecko_au2003Posted on 2005-11-16 at 09:07:46ID: 15304721
That is a lot you are asking but if you go to :
.uk
www.computerperformance.co
There are a lot of scripts relating to server side things that you are asking with explanations etc , so I would suggest you go there :)