Script to prompt for Computer Name

Posted on 2011-05-09
Last Modified: 2012-05-11
So, I have a script that is running on FirstLogonCommands after a sysprep.  This script joins the computer to the domain and adds a couple of AD groups to the local administrators list.  This is great, however, adding the "FirstLogonCommands" appears to have taken precedence over the OOBE prompt that lets me type in a unique computer name.  That being said--does anyone know of a way to make the OOBE prompt run BEFORE the firstlogoncommands executes this batch file?  If not, is there a line of code I can add to the batch file that will prompt me to enter a computer name as local administrator before it starts the process of joining the domain?

Here's my existing script:

@Echo Off
Set /P UserD=Enter a "Domain Admin" user name:
NetDom Join %COMPUTERNAME% /Domain:COMPANY.COM /UserD:%UserD% /PasswordD:* /OU:ou=WORKSTATIONS,dc=COMPANY,dc=COM
Net LocalGroup Administrators "DOMAIN\SECURITYGROUP" /add

Open in new window

Question by:DolorousDave
    LVL 21

    Accepted Solution

    First - look into using Microsoft Deployment Toolkit to deploy your machines. It is so much easier and will even prompt for a name before imaging. You type in the name and walk away.

    Attached is a vb script that will prompt for a name. Set the local administrator password at the top of the script. Have your batch file call this script.
    Name = InputBox("Enter the new computer name below and click OK to continue","Rename: Step 1")
    Username = "administrator"
    Password = "fpassword"
    Set objWMIService = GetObject("Winmgmts:root\cimv2")
    ' Call always gets only one Win32_ComputerSystem object.
    For Each objComputer in _
            Return = objComputer.rename(Name,Password,User)
            If Return <> 0 Then
               WScript.Echo "Rename failed. Error = " & Err.Number
               WScript.Echo "Rename succeeded." & " Reboot for new name to go into effect"
            End If

    Open in new window


    Author Comment

    The only problem with this is that I'd like to include it in the batch file I already have created--and that's using the netdom commands.  I don't know how to translate that script (as posted above) into a VBScript.

    Author Comment

    Ok, I see what you're saying--have the existing batch file call this script first?
    LVL 21

    Expert Comment

    by:Joseph Moody

    Author Comment

    Thank you for this great answer.  We're planning on going with the Microsoft Deployment Toolkit in the near future--right now I'm working on becoming familiar with sysprep and the answer file, etc.  I'm sure there will be questions in the near future about the MDT.  = P
    LVL 21

    Expert Comment

    by:Joseph Moody
    No problem. Feel free to email me if you have any questions. We run a fully automate MDT environment so I may be able to help.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Storage devices are generally used to save the data or sometime transfer the data from one computer system to another system. However, sometimes user accidentally erased their important data from the Storage devices. Users have to know how data reco…
    Microservice architecture adoption brings many advantages, but can add intricacy. Selecting the right orchestration tool is most important for business specific needs.
    This Micro Tutorial will give you basic overview of the control panel section on Windows 7. It will depth in Network and Internet, Hardware and Sound, etc. This will be demonstrated using Windows 7 operating system.
    This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.

    760 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

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now