Retrieving the serialnumber through a script (vbscript, powershell or bat) is not the problem. In XP I would prepare a reference computer put the script/programs to retreive the serialnumber in place and run sysprep. When sysprep completes i start regedit to change the value from key \hklm\system\setup\cmdline from setup to mybatfile.bat. This bat file retrieves the serialnumber, adjust sysprep.inf and starts the mini-setup when a computer is re-imaged. At this moment i make a ghost image which will be used on other computers. The above process worked well in XP, but in Windows 7 its not working. Microsoft changed how sysprep works in Window 7 or even before.