In our env we rely on %SERIAL% to have distinct and meaningful hostnames, with a prefix, as per line 49 of unattended.xml (attached):
We've started testing the produced ISOs in Virtual Machines, but the installation process was constantly failing after copying installation file, at first reboot, with error on:
View attachment 13254
I've troubleshooted and the issue is that NTLCompName.vbs is doing a poor job in handling the case when there's no SerialNumber, like when the VM is created in QEMU/KVM virtualization on Linux. This issues can happen when you use libvirt/Gnome Boxes on your single machine, but can also affect more structured virtualization infrastructures like oVirt/Red Hat Virtualization, KubeVirt/OpenShift Virtualization, Proxmox and likely also OpenStack, when using KVM as virtualization technology. I've never tested in major cloud providers.
The fix is quite trivial: don't assume there will be a serial at all:
NTLCompName.patch
I've also fixed a minor syntax typo.
My use case and test were limited to UEFI only and to Win11, cannot say how QEMU/KVM behave when asked a BIOS machine, but the fix should handle all cases.
Would be nice if you could incorporate the fix, to make the ISO produced by NTLite installable everywhere, also in Linux based virtualizazione envs.
Thanks
XML:
<ComputerName>PC-%SERIAL%</ComputerName>
We've started testing the produced ISOs in Virtual Machines, but the installation process was constantly failing after copying installation file, at first reboot, with error on:
Code:
C:\Windows\Setup\Scripts\NTLCompName.vbs
Invalid use of Null: 'Replace'
View attachment 13254
I've troubleshooted and the issue is that NTLCompName.vbs is doing a poor job in handling the case when there's no SerialNumber, like when the VM is created in QEMU/KVM virtualization on Linux. This issues can happen when you use libvirt/Gnome Boxes on your single machine, but can also affect more structured virtualization infrastructures like oVirt/Red Hat Virtualization, KubeVirt/OpenShift Virtualization, Proxmox and likely also OpenStack, when using KVM as virtualization technology. I've never tested in major cloud providers.
The fix is quite trivial: don't assume there will be a serial at all:
NTLCompName.patch
C#:
--- NTLCompName.vbs 2024-11-16 10:46:18.030000000 +0100
+++ NTLCompName-fix.vbs 2024-11-16 10:46:37.350000000 +0100
@@ -1,4 +1,4 @@
-'Generated by NTLite - ntlite.com
+'Generated by PCOfficina - pcofficina.org
Option Explicit
Dim unattendFile, WshShell, fso, unattendFileObject, strUnattendedAll, strPos
unattendFile = "C:\Windows\Panther\unattend.xml"
@@ -10,17 +10,21 @@
unattendFileObject.Close
strPos = InStr(strUnattendedAll, "%SERIAL%")
If strPos > 0 Then Call Query()
-wscript.Quit
+WScript.Quit
Private Sub Query()
- Dim strPos2, compNameOrig, compName, WMI, colBioses, objBios
+ Dim strPos2, compNameOrig, compName, WMI, colBioses, objBios, serialNumber
Set WMI = GetObject("WinMgmts:")
Set colBioses = WMI.InstancesOf("Win32_BIOS")
strPos = InStr(strUnattendedAll, "<ComputerName>") + 14
strPos2 = InStr(strPos, strUnattendedAll, "<")
compNameOrig = Mid(strUnattendedAll, strPos, strPos2 - strPos)
For Each objBios In colBioses
- compName = Replace(compNameOrig, "%SERIAL%", Replace(objBios.SerialNumber, " ","",1,-1))
+ serialNumber = objBios.SerialNumber
+ If IsNull(serialNumber) Or serialNumber = "" Then
+ serialNumber = "UNKNOWN" ' Fallback value if SerialNumber is null or empty
+ End If
+ compName = Replace(compNameOrig, "%SERIAL%", Replace(serialNumber, " ", "", 1, -1))
Next
compName = Left(compName, 15)
strUnattendedAll = Replace(strUnattendedAll, compNameOrig, compName)
I've also fixed a minor syntax typo.
My use case and test were limited to UEFI only and to Win11, cannot say how QEMU/KVM behave when asked a BIOS machine, but the fix should handle all cases.
Would be nice if you could incorporate the fix, to make the ISO produced by NTLite installable everywhere, also in Linux based virtualizazione envs.
Thanks