Jim's profileJim Wightman - .NET, Sil...PhotosBlogLists Tools Help

Blog


    March 01

    Using Silverlight in WindowsPE (Part 1 of 2)


    It has taken a while to get a chance to write this up but this two part blog post will give you enough information to enable Silverlight in WinPE the ‘manual’ way (part 1) and also by creating a DISM installable driver package (Part 2).

    So, part 1 first. In this post we’ll be looking at the changes we need to make to your WinPE WIM to use Silverlight, how to implement them and how to check everything is working ok. Let’s get started.

    You should have the latest WAIK installed of course since we’ll be needing the base WinPE files and DISM and the Deployment Tools command prompt. For Windows 7 you can get a copy of this here: http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=696dd665-9f76-4177-a811-39c26d3b3b34.

    As with most Windows components there are two areas we must address for Silverlight to work inside WinPE – registry entries and program files. Let’s go step-by-step through the processes necessary to discovering which registry entries we need, and which files.

    I regularly use VMWare as my Virtual Machine manager so that’s what I’ll be talking about using today. The same process can be followed using Microsoft Windows Virtual PC since we only need to leverage basic functionality such as installing an OS (and if you want to me extra-cautious, snapshots).

    Using Host PC

    1. Create a new Virtual Machine and install a Windows 7 base build.

    Inside Virtual Machine

    2. Boot into the VM and ensure no versions of Silverlight are currently installed – uninstall any versions if so.

    3. If you like, take a snapshot of the VM in it’s current state and label it ‘pre-Silverlight install’.

    4. Open Regedit and export the entire HKEY_LOCAL_MACHINE hive to a file location – perhaps even to a share on the host PC.

    5. Open a browser instance and go to http://www.microsoft.com/silverlight/get-started/install/default.aspx. Follow the prompts to install Silverlight.

    6. Optionally take another snapshot at this point and label it ‘post-Silverlight install’.

    7. Once installation has completed, open Regedit and again export the entire HKEY_LOCAL_MACHINE hive to a file location. I would suggest you give the file a suitable name suffix such as _postSilverlightInstall to identify it as being different to the previous export.

    8. Close the VM and return to working on your Host PC.

    Using Host PC

    8. Now we have a before and after snapshot of the registry we need to identify the changes so they can be imported into our WinPE registry. I personally used Beyond Compare (http://www.scootersoftware.com) and highlighted only the differences then copied/pasted them into notepad. Let’s take a look at the method using Beyond Compare.

    9. Load the two registry files created in steps 4 and 7 into Beyond Compare and wait for the differences to be identified. It should look something like this (click on the ‘show differences’ icon if it doesn’t):
     image

    10. Click on the pane showing the differences found in the post-Silverlight install exported registry file and press CTRL-A to select all entries.

    11. Open Notepad and paste in the new entries.

    We’re going to be mounting the WinPE HKLM hive using Regedit so the key names aren’t going to tally when we import these new settings. We need to modify the key paths. Before we do that however we need to use DISM.

    12. Open a Deployment Tools command prompt and mount your PE WIM to a folder using DISM. The command will look something like this:

    DISM /mount-wim /wimfile:c:\pe\winpe.wim /mountdir=c:\pe\mount /index:1

    12a. While we’re here we need to add HTA support to WinPE since we’ll be using a .hta file to host Silverlight applications. Again using DISM:

    Dism /image:C:\pe\mount /Add-Package /PackagePath:"C:\Program Files\<version>\Tools\PETools\<architecture>\WinPE_FPs\winpe-hta.cab”

    13. Now open Regedit. click on ‘HKEY_LOCAL_MACHINE’, then select ‘Load Hive…’ from the File menu. Navigate to your PE mount directory (in my case, c:\pe\mount) then navigate farther down into Windows\System32\Config. Select the file labelled SOFTWARE. When prompted, give a sensibly named key name to import under – I went for PE_SOFTWARE:

     image

    14. Looking at the text file created in step 11, we can now see that were we to try to import our ‘new’ registry keys, they would be imported to the local HKLM hive and not the WinPE hive we attached in step 13. We need to go and make a few changes to the text document containing the new registry keys. The first thing to do is to point the new registry entries at the right key for import. Using the Search and Replace function in notepad, replace all instances of HKEY_LOCAL_MACHINE\SOFTWARE with a value that points to your WinPE registry key – in my case HKEY_LOCAL_MACHINE\PE_SOFTWARE.

    15. We’re not done with the text file just yet. The more eagle-eyed amongst you will have seen that many of the values contained in the text file point to “c:|program files (x86)|Microsoft Silverlight|….”. That’s great if WinPE is configured to use C: but this isn’t default behavior…so we need to change the drive letter in the key values. Which means another global Search/Replace. This time we’re ‘finding’ c:|Program Files and replacing with x:|Program Files. Obviously if you have configured WinPE to use a different drive letter that’s the value you’ll be using.

    16. Finally we need to drop a line at the very top of the text file to identify it as a valid registry export for Regedit:

    Windows Registry Editor Version 5.00

    17. Save the text file as something like ‘silverlight_pe_registry.reg’ then, after finding it on your hard disk, double click on it and allow it to be imported into the registry (yes, you’re sure!). Alternatively, depending on the user account permissions, you might need to open Regedit again and select Import from the File menu then select the .reg file you just created.

    18. We’re done modifying the WinPE registry. You can now select the Loaded hive key (mine is PE_SOFTWARE) and use File –> Unload Hive… to unload the hive.

    19. We now need to copy the Silverlight installation files and a few other bits and pieces to the mounted WIM directories. Go back to your Win7 VM and copy the C:\Program Files\Microsoft Silverlight directory (and all subdirectories/files) into your mounted WinPE Program Files directory.

    20. From your Win7 VM (though you could get them from your host machine also, just remember not to mix 64- and 32- bit files) grab the following files and copy them to the same location under your mounted WIM directory:

    c:\windows\system32\dsound.dll

    c:\windows\system32\pdh.dll

    c:\windows\system32\pdhui.dll

    c:\windows\fonts\l_10646.ttf

    If you need to support more fonts than the default Silverlight font (l_10646.ttf) then you can copy them over too at this point. Remember the fonts available in WinPE can be limited by default so you need to copy any ‘non-standard’ fonts over if you want to use them.

    21. Before you unmount the WIM you are probably going to want to be able to test Silverlight is working inside PE. Assuming you have a simple, compiled Silverlight application to hand as a .XAP file, copy this file to the root of your mounted PE directory.

    22. Create a .HTA file in the root of the mounted PE directory. Somewhere in the <BODY> of the HTML, use the <OBJECT> tag to embed a reference to the .XAP file, like this for example (assuming your XAP file is called ‘sample.xap’):

    <object id=”SilverlightPlugin1” width=”700” height=”500” data=”data:application/x-silverlight," type="application/x-silverlight-2">
              <param name="source" value="sample.xap"/>
    </object>

    Note here that you can put the XAP file where you like but I found I had to use relative path information instead of absolute in the ‘value’ attribute of the <param> element – relative to the .HTA file location that is. For ease that’s why I’ve dropped the .HTA and .XAP file into the root directory.

    23. Unmount the WIM using DISM with a command like this:

    DISM /unmount-wim /mountdir:c:\pe\mount /commit

    24. Depending on how you’ve got things set up you may need to copy the modified WIM into the WAIK tools created ISO\sources directory and rename it to boot.wim (as you would with any modified WIM).

    25. Finally, use OSCDIMG to create the an ISO image from the WIM, using a command like this:

    OSCDIMG –n –bC:\pe\etfsboot.com c:\pe\iso c:\pe\silverlightpe.iso

    26. Boot into your new WinPE image and open the .HTA file you created in step 22. You should see your Silverlight application appear.


    And that’s it…yes it’s a bit messy and the area around adding the Silverlight registry keys needs tidying up…but it works and hopefully it’ll give you a good starting point for using Silverlight inside WindowsPE.

    Things to remember

    Ensure you don’t mix 64-bit files with 32-bit files – if you’re using WinPE 32-bit for example, you don’t want to be using installation files or registry entries from the 64-bit version of Windows 7. The same goes the opposite way. Ensure all files and registry keys are for the same processor architecture!

    Next Time…in Part 2

    I’ll take a look at getting your Silverlight application Out Of Browser (OOB) inside WinPE and also putting together a more elegant way of adding Silverlight support to a WindowsPE configuration using DISM. I’ll also look at what registry keys are getting added and why – essentially they are to enable the .HTA to handle the XAP and point it towards the Silverlight runtime – but I’ll go into this information in greater detail.

    Questions?

    If you find problems when you are following this tutorial, please leave a comment or get in touch directly. I’ll be happy to help.

    Finally, some disclaimer information.

    I haven’t tried to use Silverlight with any version of WinPE before 3.0…so mileage may vary when attempting to implement Silverlight support in any previous version.
    Implementing Silverlight support in WindowsPE is entirely unsupported by Microsoft.
    Using WindowsPE for any purpose other than recovery or deployment of an operating system is against the terms of the WinPE licence agreement.
    Follow the instructions in this article entirely at your own risk; I offer no guarantees of success nor insurance against problems that arise as a consequence.

    Someone on Windows Live

    Comments (3)

    www - Mar. 4
    http://www.pandabuy.com panda
    http://www.pandabuy.com Panda International
    http://www.pandabuy.com Health & Beauty
    http://www.pandabuy.com Health Beauty
    http://www.pandabuy.com Health Beauty supplier
    http://www.pandabuy.com Health Beauty suppliers
    http://www.pandabuy.com Health&Beauty supplier
    http://www.ismadeinchina.com Made in china
    http://www.ismadeinchina.com made in China
    http://www.pandabuy.com/Pandabuy/Product/2009107-38450.html MURAD-Day Reform Treatment 30ml/1oz
    http://www.pandabuy.com/Pandabuy/Product/20071229-35901.html JAPAN LINGZHI SLIM NATURAL TEA ,JAPAN LINGZHI SLIM NATURAL TEA,Slim Products Tea,martbase,Lida
    http://www.pandabuy.com/Pandabuy/Product/2009923-48411.html MURAD-Acne Skin Perfecting Lotion 50ml/1.7oz
    http://www.pandabuy.com/Pandabuy/Product/2009317-35518.html JIANFEIJINDAN
    http://www.pandabuy.com/Pandabuy/Product/20091029-93841.html Dmasun Fiberized Cotton Yoga Suit (TL5073+BP8113)
    http://www.pandabuy.com/productlist.aspx?ClassID=08102901521877870"
    http://www.pandabuy.com/Pandabuy/Product/20091115-75219.html CHANEL-Precision Hydramax Active Moisture Boost Fluid 50ml/1.7oz
    http://www.pandabuy.com/Pandabuy/Product/20091018-12827.html Autumn Winter Eco-friendly Cotton Yoga Suit (S145-25+P180-193-5)

    http://www.pandabuy.com/Pandabuy/Product/20091028-8748.html Dmasun Fiberized Cotton Yoga Suit (TL5040+BP8080)
    http://www.pandabuy.com/Pandabuy/Product/20091019-79829.html Autumn &amp; Winter Eco-friendly Cotton Yoga Suit (S103-02+P610-0807)
    http://www.pandabuy.com/Pandabuy/Product/20091029-1508.html Dmasun Fiberized Cotton Yoga Suit (TL5054+BP8094)
    http://www.pandabuy.com/Pandabuy/Product/20091123-9705.html 24 Hours Diet, Chain Fat Burning Reaction with Double Effects
    http://www.pandabuy.com/Pandabuy/Product/2009826-81875.html Conting Qianweisu Slimming Herbs
    http://www.pandabuy.com/Pandabuy/Product/2010120-3484.html Slimming Factor Capsule, Weight Loss Capsule, Slimming Pills
    http://www.pandabuy.com/Pandabuy/Product/20091015-8579.html Breast Enhancer
    http://www.pandabuy.com/Pandabuy/Product/2009108-21512.html MURAD-Eye Treatment Complex SPF8

    http://www.pandabuy.com/Pandabuy/Product/2009105-91720.html MURAD-Renewing Eye Cream 15ml/0.5oz
    http://www.pandabuy.com/Pandabuy/Product/20091018-21204.html Invisible Bra (09N-04)
    http://www.pandabuy.com/Pandabuy/Product/20081229-98463.html Absorbing Grease Slimming Abdomen,Slimming,Weight Loss,Slimming Capsule,Slim Pills,Best Slimming
    http://www.pandabuy.com/Pandabuy/Product/2010120-99831.html LULANJINA Special Whitening &amp; Freckle Dispelling Suit, Facial Care
    http://www.pandabuy.com/Pandabuy/Product/2009818-96600.html Shell-broken Lingzhi Spore Powder
    http://www.pandabuy.com/Pandabuy/Product/20091215-97373.html CHANEL-Allure Sensuelle Eau De Parfum Spray 50ml/1.7oz
    http://www.pandabuy.com/Pandabuy/Product/20091112-12476.html CHANEL-Precision Ultra Correction Line Repair Intensive Anti Wrinkle Concentrate 30ml/1oz
    http://www.pandabuy.com/Pandabuy/Product/200818-97005.html THE TOXIN Discharged Tea Japan Lingzhi TOXIN Discharged Tea,Japan Lingzhi Toxin-Discharged Tea is
    james - Apr. 8
    Wonder blog... Any a very good follower of your posts, and i always find it so educative and informative... Keep the brilliant work

    <a href="http://www.top3acaiberry.com">Acai Optimum</a>

    Trackbacks

    The trackback URL for this entry is:
    http://innovatotron.spaces.live.com/blog/cns!F7189E7A8A9D15A1!493.trak
    Weblogs that reference this entry
    • None