www.infralib.com

www.infralib.com
Please visit my new site http://www.infralib.com for my and other authors' newer posts, articles. We will also have forums, videos, webcasts and etc.

Thursday, 22 November 2012

Configuring regional settings automatically by using Win32_IP4RouteTable in 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, 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
installation.



And also the related error message 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.


Win32_IP4RouteTable class has two files named Wmipiprt.mof and Wmipiprt.dll 


So I wanted to include this class to my Win-PE image.

1. Preperation
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: \\yourmachine\c$ )
Copy the wmipiprt.* files to Windows\System32\wbem folder (X: Drive)
(Copy K:\windows\system32\wbem\wmipiprt.* X:\Windows\System32\wbem)
Change your working folder to X:\Windows\System32\wbem
                Cd X:\Windows\System32\wbem
Run MOF compiler for the class
Mofcomp wmipiprt.mof
Take a copy of Win-PE Wbem
                Xcopy X:\Windows\System32\wbem K:\WinpeWork\ /s /e
Register the the dll
Regsvr32 wmipiprt.dll
Backup Win-PE HKLM\Software (If you are ok the .reg file I provided you can skip all reg steps until Modifying the Image)
Reg save HKLM\SOFTWARE HKLMSoft.reg
Take a copy of exported reg file
                Copy HKLMSoft.reg K:\WinpeWork\
On your workstation
Load the C:\Winpework\HKLMSoft.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,


You’ll find two entries under CLSID, export these to .reg files and merge in one reg file. And unload the hive “WINPE”.  (You can also use the .reg below)

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\WIMSOFT\Classes\CLSID\{23B77E99-5C2D-482D-A795-62CA3AE5B673}]
@="WBEM IP Route Provider"

[HKEY_LOCAL_MACHINE\WIMSOFT\Classes\CLSID\{23B77E99-5C2D-482D-A795-62CA3AE5B673}\InprocServer32]
@="X:\\Windows\\System32\\wbem\\WMIPIPRT.dll"
"ThreadingModel"="Both"

[HKEY_LOCAL_MACHINE\WIMSOFT\Classes\CLSID\{6D7A4B0E-66D5-4AC3-A7ED-0189E8CF5E77}]
@="WBEM IP Route Event Provider"

[HKEY_LOCAL_MACHINE\WIMSOFT\Classes\CLSID\{6D7A4B0E-66D5-4AC3-A7ED-0189E8CF5E77}\InprocServer32]
@="X:\\Windows\\System32\\wbem\\WMIPIPRT.dll"
"ThreadingModel"="Both"

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:\WIMWork\x64boot.wim G:\WIMWork\x64mount
(G:\WIMWork\x64mount is an empty folder)

Open G:\WIMWork\x64mount folder, you’ll see your winpe image contents

Delete G:\WIMWork\x64mount\Windows\System32\wbem contents

Copy the K:\WinpeWork\wbem 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:\WIMWork\x64mount\Windows\System32\Config\Software 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 WIMSOFT\Classes\CLSID)

Unload WIMSOFT Hive.

Now we need to dismount the image with commit option.
Imagex /unmount /commit G:\WIMWork\x64mount
Finished.
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.

No comments: