Quantcast
Channel: Windows 8.1 Installation, Setup, and Deployment forum
Viewing all articles
Browse latest Browse all 5362

How to edit the Unattend with a custom Asset based computer name during setup?

$
0
0

I really hope someone has tackled this in Windows 8.1...

So with the "no computer name prompt" in Windows 7/8 we have had trouble in the past with naming the computers (we deploy hundreds per month, this next project is for 6500) So our base image has everything configured just plug into the network and boot, we want it to name it a Pre-fix + Asset. I have all the scripts written and they work great - it checks the Asset tag field in bios from a WMI query and than uses "RR"+AssetTag as a variable, than it reads the unattned.xml file and replaces the computer name ("name_this") in the unattend.xml

However.... I am having trouble getting the script to run during the setup, it seems to never change the "name_this"

This is my unattned.xml (any help is appreciated) - shortened

   <settings pass="specialize">
        <component name="Microsoft-Windows-Deployment" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <RunSynchronous>
                <RunSynchronousCommand wcm:action="add">
                    <Order>1</Order>
                    <Path>net user administrator /active:yes</Path>
                </RunSynchronousCommand>
            </RunSynchronous>
            <RunAsynchronous>
                <RunAsynchronousCommand wcm:action="add">
                    <Description>Rename &quot;name_this&quot; in unattend</Description>
                    <Order>1</Order>
                    <Path>cscript.exe %systemroot%\System32\Sysprep\customsysprep\EditUnattend.vbs</Path>
                </RunAsynchronousCommand>
            </RunAsynchronous>
        </component>
        <component name="Microsoft-Windows-Security-SPP-UX" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <SkipAutoActivation>true</SkipAutoActivation>
        </component>
        <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <CopyProfile>true</CopyProfile>
            <TimeZone>Pacific Standard Time</TimeZone>
            <ComputerName>name_this</ComputerName>
        </component>

Here is my script..

Dim answer, strcomputerName, unattendFile, WshShell, fso, unattendFileObject, strContents, assetfile, AssetFileObject, Asset


arrComputers = Array("NAME_THIS")

unattendFile = "C:\Windows\Panther\unattend.xml"
Set WshShell = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")

For Each strComputer In arrComputers
     Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
   Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_SystemEnclosure", "WQL", _
                wbemFlagReturnImmediately + wbemFlagForwardOnly)

   For Each objItem In colItems
      Asset="RR" & objItem.SMBIOSAssetTag

Next
Next
Set unattendFileObject = fso.OpenTextFile(unattendFile, 1)
strContents = unattendFileObject.ReadAll
strContents = Replace(strContents, "name_this", Asset)
strContents = Replace(strContents, "USERASSETDATA.ASSET_NUMBER=", "RR")
unattendFileObject.Close
Set unattendFileObject = fso.OpenTextFile(unattendFile, 2)
unattendFileObject.Write(strContents)
unattendFileObject.Close

'For testing the script
WScript.Echo Asset


Viewing all articles
Browse latest Browse all 5362

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>