locked
Unable to Use a UserExit Script to Pull Offline Computer Name RRS feed

  • Question

  • We are using WDS and MDT 2013 to deploy Windows 10. We've been set up this way for bit more than a year. For most of this time, we have been able to use UserExit to automatically fill in the computer's name inside the interface. It's worked pretty well and it helps eliminate tiny mistakes in name schemes. However, we recently noticed it is no longer working. Just noticed it when deploying today, but we don't do a lot of deployments all of the time. As far as I know, nothing has changed in the environment to make this happen. 

    In our Rules, we have this set:

    [Default]
    UserExit=UserExit.vbs
    OSDComputername=#GetOfflineComputername()#

    UserExit.vbs looks like this:

    Function UserExit(sType, sWhen, sDetail, bSkip)
    	oLogging.CreateEntry "entered UserExit ", LogTypeInfo
    	UserExit = Success
    End Function
    
    Function GetOfflineComputername()
    On Error Goto 0
    
    	If oEnvironment.Item("OSVERSION")="WinPE" Then
    		Dim CompName : CompName = ""
    		Dim ret, sOldSystem : sOldSystem = ""
    		For Each drv In Array("C", "D", "E", "F")
    			If ofso.FileExists(drv & ":\windows\system32\config\system") Then
    				sOldSystem = drv & ":\windows\system32\config\system"
    				Exit For
    			End If
    		Next
    		oLogging.CreateEntry "Mounting Offline registry " & sOldSystem, LogTypeInfo
    		ret = oShell.Run ("reg load HKLM\z " & sOldSystem, 0, True)
    		If ret = 0 Then
    			CompName = oShell.RegRead("HKLM\z\ControlSet001\Services\Tcpip\Parameters\Hostname")
    
    			
    			If CompName <> "" Then
    				oLogging.CreateEntry "Found old computername '" & CompName & "'", LogTypeInfo
    			Else
    				oLogging.CreateEntry "Old computername name could not be found", LogTypeWarning
    			End If
    		Else
    			oLogging.CreateEntry "Could not mount offline registry " & sOldSystem, LogTypeWarning
    		End If
    		oShell.Run "REG UNLOAD HKLM\Z", 0, True		
    	Else
    		CompName = oShell.ExpandEnvironmentStrings("%Computername%")
    	End If
    
    	GetOfflineComputername = CStr(CompName)
    		
    End Function

    I've also tried using ("HKLM\z\ControlSet001\Control\ComputerName\ComputerName\ComputerName") as the registry key, since it seems to also store the computer name. No luck. What's even more strange, is our other domain is working fine with this same UserExit setup. I tried copying that file over as well just incase there's something weird, no luck. I have been fully regenerating the boot images and re-adding them to WDS between each change to make sure things take effect. 

    In the BDD.log, I find: "No value found for ComputerName", which isn't anywhere in that VBS script so I'm not sure where that text is generated. I searched BDD.log for all 3 of the strings that are logged in that VBS script and found nothing.

    Here's the full BDD.log, minus the ZTIDrivers and ZTIApplications steps (since I am limited to 512KB on pastebin): https://pastebin.com/s9NAeR0V

    Friday, July 21, 2017 5:53 PM

All replies

  • Turns out, the issue was this section:

    [Default]
    UserExit=UserExit.vbs
    OSDComputername=#GetOfflineComputername()#

    was in the CustomSettings.ini two times. I removed the duplicate and all went back to normal. 

    • Proposed as answer by Anton Romanyuk Thursday, February 22, 2018 9:22 PM
    Thursday, February 22, 2018 8:52 PM