In the situation where you want to reinstall a PC using a Standalone media, you will have to incorporate some way of naming the PC, or it will pick up a random name like MININT-XXXXX.

In a reinstallation scenario however, the PC will already have a Name assigned, and this name can quiet easily be picked up from the computers registry hive files.

To do this just run this .vbs script, before formatting the disk. It will pick up the name and assign it to the OSDComputerName variable, which will automatically be added to the Unattend.xml (or sysprep.inf if XP)

1 Set oShell = WScript.CreateObject("WScript.Shell") 2 Set env = CreateObject("Microsoft.SMS.TSEnvironment") 3 4 oShell.Run "cmd.exe /c REG LOAD HKLM\TempHive C:\windows\system32\config\system",0,True 5 6 env("OSDComputerName") = oShell.RegRead("HKLM\TempHive\ControlSet001\Control\ComputerName\ComputerName\computername")

 

If the drive holding the original OS does not resolve to C: just change that part of the script…