Batch file help

I am searching for a batch file that will allow me to rename a computer and join it to a windows domain.  
Here is some helpful information:  
Domain Name -
Please input "pc-name" where the new computer name would go and if it requires a username or password please let me know where to input these at.

Greg StewartNetwork AdministratorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NVITEnd-user supportCommented:
Make a .bat file to rename the computer:
@echo off
rem Pre-requisite Step: Change CheckDomain to the name of your domain.
rem To find your domain name:
rem - Go to a computer already joined to the domain.
rem - See the value next to: Workstation domain

rem Prompt whoever is running the script for a new computer name.
set /p NewName=Enter computer name (no spaces please): 

rem Get machine's domain name
for /f "tokens=1-3 delims= " %%d in ('net config workstation ^| findstr /c:"Workstation 

domain"') do set machinedomain=%%f

rem If the computer is joined to a domain, notify user and not allow name change.
rem If not a domain member then proceed with name change.
if /i "%machinedomain%" equ "%CheckDomain%" (
  echo Cannot rename this computer.
  echo This computer %computername% is already part of domain %CheckDomain%
) else (
  WMIC computersystem where caption='%computername%' rename %NewName%
  echo Successfully renamed 
  echo Rebooting...
  shutdown /f /r

Open in new window

Make a .bat to join domain:
rem Get machine's domain name
for /f "tokens=1-3 delims= " %%d in ('net config workstation ^| findstr /c:"Workstation 
domain"') do set machinedomain=%%f

netdom /domain:%machinedomain% /user:domainadminname /password:nottelling member %computername% /joindomain
echo Rebooting...
shutdown /f /r

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.