Package Scanner – Command Line Servicing for Windows Embedded

Microsoft

bloggers

discussions

Package Scanner – Command Line Servicing for Windows Embedded

  • Comments 0

* Update 9/23 – added pictures

During the course of our development of Windows Embedded Standard 2011, we realized that our embedded customers have slightly different needs than Windows Client customers with regard to how devices are serviced. For instance, embedded devices can have very limited disk space, while desktop computers can have hundreds of gigabytes of free space. Embedded devices are often not connected to the internet, while most home and office computers are.

Differences like these can affect the way devices are serviced dramatically, so our team created Package Scanner to help service embedded devices more easily.

What does Package Scanner do?

Package Scanner has three main functions:

  • Package Enumeration

This function scans your Windows Embedded Standard 2011 OS and returns a list of any packages installed. This includes the original packages you selected in ICE or IBW, and any update packages you applied over the lifetime of your device.

  • Find Applicable Updates

This function is helpful for offline servicing your device. If your device isn’t connected to the internet, then you can’t run Windows Update. Without Windows Update, you’re going to have to manually download updates somewhere and determine which ones are applicable to your device’s configuration. This function will scan a folder full of updates and determine which updates are applicable.

  • Package Scavenging

Over the lifetime of your device, it’s quite likely that you’ll install many updates. By default with Windows, when you install an update, the old, updated files remain on the device so that you can uninstall the update if you want to. Over time, all of these older files on your system can take up valuable space in embedded devices. This function removes staged and superseded packages.

Where do I find Package Scanner?

Package Scanner is installed along with Image Configuration Editor.

The 32 bit version of Package Scanner (which can be used to scan x86 Windows Embedded Standard 2011 images) is under:

{Install Location}\Tools\Image Configuration Editor\PkgScn.exe

For CTP1 of Windows Embedded Standard 2011, there is no 64 bit version of Package Scanner, so scanning your x64 images won’t work.

Post CTP1, the 64 bit version of Package Scanner will be located under:

{Install Location}\Tools\x64 Apps\PkgScn.exe

How do I run it?

If you simply type Pkgscn.exe from Package Scanner’s home directory, you’ll get the usage dialog below that explains all the functionality:

image

Package Scanner can be run in two modes: offline and online.

  • “Offline” is executing Package Scanner against a Windows Embedded Standard 2011 image that is not currently running. For example, if you took the primary hard drive (which contains your installed Windows Embedded Standard 2011 image) out of your device and plugged it into your development computer, pointing Package Scanner to the OS files on that hard drive would be considered scanning offline. The same applies if you were to capture your Windows Embedded Standard 2011 image to a WIM file and mount it on your development computer, or if you were to boot into WinPE or another operating system on your device and point Package Scanner to the Windows Embedded Standard 2011 files. As long as you can point Package Scanner to the OS files while the target OS isn’t actually running, you’re scanning offline.
  • “Online” is executing Package Scanner against a Windows Embedded Standard 2011 image that is currently running. Boot up your device into Windows Embedded Standard 2011 and run package scanner from within Windows Embedded Standard 2011, and you’re scanning online.

By default, Package Scanner assumes it’s running online. If you try and execute one of Package Scanner’s commands on a non- Windows Embedded Standard 2011 image, you’ll get a friendly error message telling you that won’t work. To tell Package Scanner to run against an offline image, use the /Image: flag, and point it at the root of your Quebec image.

To run Package Scanner online, you’ll need to copy Pkgscn.exe and some other necessary files to your target device. To make that process a bit easier for you, we’ve included CopyPkgScn.cmd, which is located in the same directory as Pkgscn.exe. If you have write privileges to the current directory, you can just double click CopyPkgScn.cmd to have it create a PkgScn folder. Otherwise, you can run CopyPkgScn.cmd from a command prompt to specify a target directory.

Once you’ve run CopyPkgScn.cmd, you’ll end up with a folder that contains PkgScn.exe and other files that are required for Package Scanner to run. You can copy this folder to your target device, to a network share, or even to your WinPE disk.

Determining what’s in your image (/Get-Packages)

The first of Package Scanner’s three main functions is package enumeration. The /Get-Packages command will list every package installed in your image. This includes the original packages you configured in ICE or IBW, as well as any packages you added later with DISM, or any updates you applied.

image

In addition to simply listing the packages in your image, you can also use the /ConfigSetDir: option to create a configset with an answer file listing all of your installed packages.

image

You can use this answer file to simply have a record of what’s installed, or you can open this answer file in ICE to build more images with the same packages and updates as the scanned image. Note that any settings you configured in your original answer file or any 3rd party files you added won’t be included in your Package Scanner /Get-Packages answer file.

Finding updates applicable to your image (/Find-Updates)

Package Scanner’s second function is /Find-Updates.

The easiest way to keep your Windows images up-to-date is using Windows Update. Configure the service to automatically download and install updates, and your device will be pretty close to maintenance free.

However, for many Windows Embedded customers, Windows Update isn’t the perfect solution, as you may want to maintain a finer level of control over which updates should be applied or your device might not be plugged into a network.

Sample Scenario:

You manage six Windows Embedded Standard 2011-based devices, all with different package configurations. None of your devices have network access, so Windows Update isn’t an option. You download all updates for Windows Embedded Standard 2011 from the ECE site into a folder on your development computer.

Now, how can you figure out which updates should be applied to each device?

Pkgscn.exe /Find-Updates to the rescue!

To use /Find-Updates, you’ll need a folder of update files. They can be in .CAB or .MSU format. If you point Package Scanner to this folder and to your target image, it will let you know which updates are applicable to your image. It’ll even check to see if there are updates you have that are newer than other updates, and only show you the “latest and greatest” updates for your image.

To use the /Find-Updates option, you’ll also need to use /PackagePath: to point to your updates folder. If you’re testing out one of our CTP builds, you can find a folder of test updates on your x86 and amd64 IBW disks.

image

If you add the /ConfigSetDir: option to /Find-Updates, you’ll create a configuration set with a directory structure something like this:

image

Inside, you’ll find AutoUnattend.xml, which is your answer file that tells the Windows servicing stack what packages it should install. You’ll also find copies of the update packages that apply to your image. The AutoUnattend.xml file points to these local copies so they can be easily accessed.

Once you’ve created your configset, you can apply it via DISM, which is the main command line servicing tool for Windows 7. In the example below, you’ll see that we’re telling DISM to apply the unattend file from our configset. In this case, our configset is located at c:\cfs on the Windows Embedded Standard 2011 runtime, so we’re running DISM with the /online option. If you’d like to apply the updates offline, you can use the /Image: option in DISM to point to your Windows Embedded Standard 2011 image.

If you’re applying the updates online, you may be prompted to reboot your device to finish installation.

Removing unneeded packages (/Find-Scavenge)

The final function of Package Scanner is package scavenging via the /Find-Scavenge command. Here’s how scavenging comes in useful:

Over the lifetime of your device, you’re likely to install a large number of updates. When you install an update, Windows will keep around the old versions of the updated binaries in case you’d like to uninstall the update. For Client Windows, this behavior is fine, as consumers may want to roll back, and they’ve got plenty of disk space to store old files. In embedded land however, you might not care about uninstalling updates, and your disk space may be severely limited. In that case, removing the old binaries may help you out.

To show you how scavenging works, I set up a test environment that simulates servicing over time.

image

You can see from the output of /Get-Packages that I’ve installed 6 test updates on my device. Three of these updates are “Version 1” updates, and the other three are “Version 2” updates, meaning that they update the updated version.

You can see in the lower half of the output that the Version 1 updates (6.1.1.1) have been superseded by the Version 2 updates (6.1.2.1). These are eligible for scavenging.

We can run Package Scanner with the /Find-Scavenge and /ConfigSetDir: flags to detect these scavengable packages and create an answer file with the packages to be removed.

image

Finally, just like we did with /Find-Updates, we can use DISM to apply the answer file, and remove the unwanted packages.

image

Now, the packages have been removed, your system is still stable and you’ve saved yourself a bit of disk space. All is well.

So, if you think Package Scanner might be useful for your servicing needs, please give it a try and let me know how it works for you.

Thanks for reading, and if you’ve got any questions, comments, or suggestions about Package Scanner, comment on this blog article and I’ll get back to you.

-Robert

Technorati Tags: XPe,Standard 2009,Quebec

blog comments powered by Disqus