Configuring location based settings automatically by using Win32 IP4RouteTable in OSD – Task Sequence
The idea was creating location specific variable sets to automatically configure regional settings during deployment.
Select * FROM Win32_IP4RouteTable WHERE Destination='0.0.0.0' AND ( NextHop='10.99.0.254' OR NextHop='10.101.0.254' OR NextHop='10.103.0.254' OR NextHop='10.104.0.254' )
The query above is very useful as it queries the routing table to find gateway and it looks ok when you run test it in SCCM Console.
But, it doesn’t work and generates errors below during deployment
(You can use VB, PS scripts, Control.exe with .xml file or other methods by using same WMI query after Setup Windows & CM action (Windows Mode) to set regional settings, they should be easier. But I wondered if I can fix that one, as I always have used default boot images provided in WAIK and I wanted to gain some familiarity with WinPE imaging/tools. I am sure the method below may not be the good/best practise but that is what I did in last few hours, it was good experimental work for me and I believe some parts can be useful for others as well.)
Windows could not parse or process the unattended answer file for pass [specialize]. The settings specified in the answer file cannot be applied. The error was detected while processing settings for component [Microsoft-Windows-Shell-Setup].
If you click ok to Restart/OK, it goes in to reboot loop with message below.The computer restarted unexpectedly or encountered an unexpected error. Windows installation cannot proceed. To install Windows, click “OK” to restart the computer, and then restart the
And also the error message below can be found in advertisement status messages.
If you check sms*.log files in deployment client drive you can also find error messages related to operands. (Attaching .vhd is very useful to do that.)
Reason ? The reason is Win32_IP4RouteTable class is invalid as it is not included in winpe-wmi.cab.
(For more details : http://msdn.microsoft.com/en-gb/library/windows/desktop/aa394162(v=vs.85).aspx)
So I wanted to include this class to my Win-PE image.
Enable command support option in your current boot image, start deployment but don’t select TS and proceed to installation.
Press F8 to open command prompt
- Connect to your workstation
- (net use K: \yourmachinec$ )
- Copy the wmipiprt.* files to WindowsSystem32wbem folder (X: Drive)
- (Copy K:windowssystem32wbemwmipiprt.* X:WindowsSystem32wbem)
- Change your working folder to X:WindowsSystem32wbem
- Cd X:WindowsSystem32wbem
- Run MOF compiler for the class
- Mofcomp wmipiprt.mof
- Take a copy of Win-PE Wbem
- Xcopy X:WindowsSystem32wbem K:WinpeWork /s /e
- Register the the dll
- Regsvr32 wmipiprt.dll
- Backup Win-PE HKLMSoftware (If you are ok the .reg file I provided you can skip all reg steps until Modifying the Image)
- Reg save HKLMSOFTWARE HKLMSoft.reg
- Take a copy of exported reg file
- Copy HKLMSoft.reg K:WinpeWork
On your workstation
Load the C:WinpeworkHKLMSoft.reg file with load hive option to your workstations HKLM, you can use any name for Hive name (e.g. WINPE)
Then search wmipiprt in loaded hive,
Windows Registry Editor Version 5.00
@="WBEM IP Route Provider"
@="WBEM IP Route Event Provider"
2. Modifying the image (Be sure you have a backup of your original boot image in separate place.)
Mount your boot image in writable mode.
Imagex /mountrw G:WIMWorkx64boot.wim G:WIMWorkx64mount
(G:WIMWorkx64mount is an empty folder)
Open G:WIMWorkx64mount folder, you’ll see your winpe image contents
Delete G:WIMWorkx64mountWindowsSystem32wbem contents
Copy the K:WinpeWorkwbem content you have copied from running Win-PE to your work folder in first steps of Preparation above.
Run Regedit, select HKLM then select load hive from menu,
Select G:WIMWorkx64mountWindowsSystem32ConfigSoftware to load and give WIMSOFT as a name if you are going to use my .reg file above.
Run the .reg you’ve created by correcting paths or directly the one above.
(Check two new entries under WIMSOFTClassesCLSID)
Unload WIMSOFT Hive.
Now we need to dismount the image with commit option.
Imagex /unmount /commit G:WIMWorkx64mount
Take a backup of your current boot image on SCCM, copy this one to your source and update your distribution points to test. (Or create a new image, to test first.)
Now you can use Win32_IP4RoutingTable in Win-PE mode.
Place your variable set tasks just before the Configure action in PostInstall phase.