Discussion:
Windows 7 Enterprise sysprep deployment - how to prompt for computer name?
(too old to reply)
George
2009-11-24 07:19:04 UTC
Permalink
Back in Windows XP, when you used Sysprep to set up a machine for a
user, it was easy to get it to prompt for a computer name during
Sysprep's run.

Now with Win7, Microsoft, for whatever reason, seems to have gotten
rid of this ability.

As far as I can tell, you can either put a * into your unattend.xml
file so that it creates a random name, or enter in a name directly
into the XML file, which it will then use. This of course is not
helpful in an environment where this image will be ghosted onto
hundreds of PC's. They certainly cannot all have the same name.

Problem is, neither is a great option. I would like to get Windows 7
to prompt for a name, that the tech prepping the machine could type
in. (We use the computer's asset tag as the computer name, which is
quite helpful to us).

I've seen this question asked before on other forums, and have found
several web pages where people ask this same question, but so far the
only thing I've heard that might work is this utility somebody wrote
called "mysysprep2" This sounds interesting, but if possible I would
prefer to not use third party utilities.

Thank you in advance for any possible help or hints.
Dusko Savatovic
2009-11-24 19:54:58 UTC
Permalink
To be prompted for computer name, just delete the line
<ComputerName>*</ComputerName>
from your unattend.xml.
Post by George
Back in Windows XP, when you used Sysprep to set up a machine for a
user, it was easy to get it to prompt for a computer name during
Sysprep's run.
Now with Win7, Microsoft, for whatever reason, seems to have gotten
rid of this ability.
As far as I can tell, you can either put a * into your unattend.xml
file so that it creates a random name, or enter in a name directly
into the XML file, which it will then use. This of course is not
helpful in an environment where this image will be ghosted onto
hundreds of PC's. They certainly cannot all have the same name.
Problem is, neither is a great option. I would like to get Windows 7
to prompt for a name, that the tech prepping the machine could type
in. (We use the computer's asset tag as the computer name, which is
quite helpful to us).
I've seen this question asked before on other forums, and have found
several web pages where people ask this same question, but so far the
called "mysysprep2" This sounds interesting, but if possible I would
prefer to not use third party utilities.
Thank you in advance for any possible help or hints.
George
2009-12-11 18:51:40 UTC
Permalink
Post by Dusko Savatovic
To be prompted for computer name, just delete the line
<ComputerName>*</ComputerName>
from your unattend.xml.
Dusko,

Your suggestion worked very well!

However, by deleting that one line what now happens is the machine
won't properly add to our AD. It acts like it was added, and the
machine even shows as being added to our domain, but it does not
appear on our domain. The computer name cannot be found anywhere. If
I add back the line about the computer name (so that once again it
gets a random name) it will then properly be added to the domain and
work normally.

Here is the command I use to launch sysprep (maybe I have to change
something?)

sysprep /generalize /oobe /shutdown /unattend:sysprep.xml
Dusko Savatovic
2009-12-13 23:11:21 UTC
Permalink
George,

I noticed that myself too. In fact I don't automatically join sysprepped
machines to domain since Windows XP. IMHO it's simply not worth the effort.
There's always something that goes wrong. One of the reasons that I don't do
automatic join is because where I work, the person who installs the systems
is never an end user. Instead I use a vbs script. I usually put it on the
deployment share. The account used for joining is:
a) account with delegated rights to join computers in a designated OU.
b) is not member of domain admins group.
c) is active only during deployment session.
d) is assigned user right to deny log on locally.

You may choose to include the script in your image and invoke it during the
first run.

The script follows. Take care of the long lines that wrap.

<script>

Const JOIN_DOMAIN = 1
Const ACCT_CREATE = 2

strDomain = "contoso.com"
strUser = "deployment"
strPassword = "K3UWtn4ru72j"
strOU = "OU=Deployment Project,DC=contoso,DC=com"

Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName

Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" &
strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & strComputer & "'")

objComputer.JoinDomainOrWorkGroup strDomain, strPassword, strDomain & "\" &
strUser, strOU, JOIN_DOMAIN + ACCT_CREATE

</script>
Post by George
Post by Dusko Savatovic
To be prompted for computer name, just delete the line
<ComputerName>*</ComputerName>
from your unattend.xml.
Dusko,
Your suggestion worked very well!
However, by deleting that one line what now happens is the machine
won't properly add to our AD. It acts like it was added, and the
machine even shows as being added to our domain, but it does not
appear on our domain. The computer name cannot be found anywhere. If
I add back the line about the computer name (so that once again it
gets a random name) it will then properly be added to the domain and
work normally.
Here is the command I use to launch sysprep (maybe I have to change
something?)
sysprep /generalize /oobe /shutdown /unattend:sysprep.xml
Rainsy Jolink
2009-12-31 07:51:01 UTC
Permalink
Easy way is:
put back the line <ComputerName>*</ComputerName>
So the computer wil join domain automaticly with a random made computername.
And then in the oobesystem pass use the shell setup to autologin and the
fistlogoncommand to run a rename script. When the computer is @ the end of
the install in will logon and run the script the tech just have to type in
the computername and enter.

rename.vbs:
Rename_Computer()

' ------ RENAME COMPUTER ------
Sub Rename_Computer
Dim strNewComputer, objNetwork, objWMIService, colComputers
Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colComputers = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
strNewComputer = InputBox("Vul hier de computernaam in!",Title)
For Each objComputer in colComputers
err = objComputer.Rename (strNewComputer)
Next
Call Reboot()
End Sub
'------ END RENAME COMPUTER -----------

'------ REBOOT MACHINE -------------
Sub Reboot
Dim oWMI, oOS, obj
Set oWMI =
GetObject("winmgmts:{impersonationLevel=impersonate,(Shutdown)}!\\.\root\cimv2")
On Error GoTo 0
For Each obj in oWMI.ExecQuery("Select * from Win32_OperatingSystem")
Set oOS = obj
Exit For
Next
Const EWX_LOGOFF = 0
Const EWX_SHUTDOWN = 1
Const EWX_REBOOT = 2
Const EWX_FORCE = 4
Const EWX_POWEROFF = 8
oOS.Win32shutdown EWX_REBOOT '+ EWX_FORCE
End Sub

' ------- END REBOOT MACHINE ---------
Post by Dusko Savatovic
George,
I noticed that myself too. In fact I don't automatically join sysprepped
machines to domain since Windows XP. IMHO it's simply not worth the effort.
There's always something that goes wrong. One of the reasons that I don't do
automatic join is because where I work, the person who installs the systems
is never an end user. Instead I use a vbs script. I usually put it on the
a) account with delegated rights to join computers in a designated OU.
b) is not member of domain admins group.
c) is active only during deployment session.
d) is assigned user right to deny log on locally.
You may choose to include the script in your image and invoke it during the
first run.
The script follows. Take care of the long lines that wrap.
<script>
Const JOIN_DOMAIN = 1
Const ACCT_CREATE = 2
strDomain = "contoso.com"
strUser = "deployment"
strPassword = "K3UWtn4ru72j"
strOU = "OU=Deployment Project,DC=contoso,DC=com"
Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName
Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" &
strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & strComputer & "'")
objComputer.JoinDomainOrWorkGroup strDomain, strPassword, strDomain & "\" &
strUser, strOU, JOIN_DOMAIN + ACCT_CREATE
</script>
Post by George
Post by Dusko Savatovic
To be prompted for computer name, just delete the line
<ComputerName>*</ComputerName>
from your unattend.xml.
Dusko,
Your suggestion worked very well!
However, by deleting that one line what now happens is the machine
won't properly add to our AD. It acts like it was added, and the
machine even shows as being added to our domain, but it does not
appear on our domain. The computer name cannot be found anywhere. If
I add back the line about the computer name (so that once again it
gets a random name) it will then properly be added to the domain and
work normally.
Here is the command I use to launch sysprep (maybe I have to change
something?)
sysprep /generalize /oobe /shutdown /unattend:sysprep.xml
.
jamie richards
2011-03-03 16:38:47 UTC
Permalink
When I run this it displays an error for Line 23:

Set oWMI =

Is there something missing after the equal sign?

Thanks

Jamie
Post by George
Back in Windows XP, when you used Sysprep to set up a machine for a
user, it was easy to get it to prompt for a computer name during
Sysprep's run.
Now with Win7, Microsoft, for whatever reason, seems to have gotten
rid of this ability.
As far as I can tell, you can either put a * into your unattend.xml
file so that it creates a random name, or enter in a name directly
into the XML file, which it will then use. This of course is not
helpful in an environment where this image will be ghosted onto
hundreds of PC's. They certainly cannot all have the same name.
Problem is, neither is a great option. I would like to get Windows 7
to prompt for a name, that the tech prepping the machine could type
in. (We use the computer's asset tag as the computer name, which is
quite helpful to us).
I have seen this question asked before on other forums, and have found
several web pages where people ask this same question, but so far the
called "mysysprep2" This sounds interesting, but if possible I would
prefer to not use third party utilities.
Thank you in advance for any possible help or hints.
Post by Dusko Savatovic
To be prompted for computer name, just delete the line
<ComputerName>*</ComputerName>
from your unattend.xml.
Post by George
Dusko,
Your suggestion worked very well!
However, by deleting that one line what now happens is the machine
will not properly add to our AD. It acts like it was added, and the
machine even shows as being added to our domain, but it does not
appear on our domain. The computer name cannot be found anywhere. If
I add back the line about the computer name (so that once again it
gets a random name) it will then properly be added to the domain and
work normally.
Here is the command I use to launch sysprep (maybe I have to change
something?)
sysprep /generalize /oobe /shutdown /unattend:sysprep.xml
Post by Dusko Savatovic
George,
I noticed that myself too. In fact I do not automatically join sysprepped
machines to domain since Windows XP. IMHO it is simply not worth the effort.
There is always something that goes wrong. One of the reasons that I do not do
automatic join is because where I work, the person who installs the systems
is never an end user. Instead I use a vbs script. I usually put it on the
a) account with delegated rights to join computers in a designated OU.
b) is not member of domain admins group.
c) is active only during deployment session.
d) is assigned user right to deny log on locally.
You may choose to include the script in your image and invoke it during the
first run.
The script follows. Take care of the long lines that wrap.
<script>
Const JOIN_DOMAIN = 1
Const ACCT_CREATE = 2
strDomain = "contoso.com"
strUser = "deployment"
strPassword = "K3UWtn4ru72j"
strOU = "OU=Deployment Project,DC=contoso,DC=com"
Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName
Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" &
strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & strComputer & "'")
objComputer.JoinDomainOrWorkGroup strDomain, strPassword, strDomain & "\" &
strUser, strOU, JOIN_DOMAIN + ACCT_CREATE
</script>
Post by Rainsy Jolink
put back the line <ComputerName>*</ComputerName>
So the computer wil join domain automaticly with a random made computername.
And then in the oobesystem pass use the shell setup to autologin and the
the install in will logon and run the script the tech just have to type in
the computername and enter.
Rename_Computer()
' ------ RENAME COMPUTER ------
Sub Rename_Computer
Dim strNewComputer, objNetwork, objWMIService, colComputers
Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colComputers = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
strNewComputer = InputBox("Vul hier de computernaam in!",Title)
For Each objComputer in colComputers
err = objComputer.Rename (strNewComputer)
Next
Call Reboot()
End Sub
'------ END RENAME COMPUTER -----------
'------ REBOOT MACHINE -------------
Sub Reboot
Dim oWMI, oOS, obj
Set oWMI =
GetObject("winmgmts:{impersonationLevel=impersonate,(Shutdown)}!\\.\root\cimv2")
On Error GoTo 0
For Each obj in oWMI.ExecQuery("Select * from Win32_OperatingSystem")
Set oOS = obj
Exit For
Next
Const EWX_LOGOFF = 0
Const EWX_SHUTDOWN = 1
Const EWX_REBOOT = 2
Const EWX_FORCE = 4
Const EWX_POWEROFF = 8
oOS.Win32shutdown EWX_REBOOT '+ EWX_FORCE
End Sub
' ------- END REBOOT MACHINE ---------
Submitted via EggHeadCafe
Pass Values Between Windows Forms
http://www.eggheadcafe.com/tutorials/aspnet/a3e1e170-21d9-4a59-a659-3ead05bb36f2/pass-values-between-windows-forms.aspx
Loading...