Thursday 22 November 2012

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.

1  2

 
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].

 3
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
installation.

4

And also the error message below can be found in advertisement status messages.

5

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.

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

(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.

 

1. Preperation

Enable command support option in your current boot image, start deployment but don’t select TS and proceed to installation.

7

Press F8 to open command prompt

  1. Connect to your workstation

    • (net use K: \yourmachinec$ )



  2. Copy the wmipiprt.* files to WindowsSystem32wbem folder (X: Drive)

    • (Copy K:windowssystem32wbemwmipiprt.* X:WindowsSystem32wbem)



  3. Change your working folder to X:WindowsSystem32wbem

    • Cd X:WindowsSystem32wbem



  4. Run MOF compiler for the class

    • Mofcomp wmipiprt.mof



  5. Take a copy of Win-PE Wbem

    • Xcopy X:WindowsSystem32wbem K:WinpeWork /s /e



  6. Register the the dll

    • Regsvr32 wmipiprt.dll



  7. 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



  8. 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)

8

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: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


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.)

10

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:

Post a Comment