• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1016
  • Last Modified:

Script to prompt for Computer Name

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:
Echo.
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

0
DolorousDave
Asked:
DolorousDave
  • 3
  • 3
1 Solution
 
Joseph MoodyBlogger and wearer of all hats.Commented:
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 _
    objWMIService.InstancesOf("Win32_ComputerSystem")

        Return = objComputer.rename(Name,Password,User)
        If Return <> 0 Then
           WScript.Echo "Rename failed. Error = " & Err.Number
        Else
           WScript.Echo "Rename succeeded." & " Reboot for new name to go into effect"
        End If
Next

Open in new window

0
 
DolorousDaveAuthor Commented:
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.
0
 
DolorousDaveAuthor Commented:
Ok, I see what you're saying--have the existing batch file call this script first?
0
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 
Joseph MoodyBlogger and wearer of all hats.Commented:
Yep!
0
 
DolorousDaveAuthor Commented:
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
0
 
Joseph MoodyBlogger and wearer of all hats.Commented:
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.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now