[VBScript] Aunty Mel's Cheap And Nasty SxS Package Extractor (Updated 2013/11/09) Disclaimer This script is provided 'as-is' WITHOUT ANY WARRANTY WHATSOEVER, including, but not limited to, warranties of merchantability, fitness for purpose, actually working, not reformatting your hard disk, not consuming your children, and not destroying the universe. In no event will the author(s) or copyright holder(s) be held liable for any damages caused by the use of, or the inability to use, this script. The entire risk arising out of use and/or performance of this script remains solely with you. Note that some juristictions do not allow the exclusion or limitation of implied warranties or liability for incidental damages. This script MAY NOT be exported to, acquired in, downloaded in, hosted in, accessed in, or used in such juristictions where these implied warranties and/or liabilities for damages cannot be completely excluded. Getting the picture yet? USE AT YOUR OWN RISK. What does it do? May I present the (apparently?) long-awaited Aunty Mel's Cheap And Nasty SxS Package Extractor. Updated on 2013/11/09, now with a cheesy scent. I had no idea there was any demand for such a tool outside of reboot.pro, but this thread set me straight. It's a Windows Side-by-Side assembly/package extractor. If you don't know what that means, this script is going to be absolutely useless to you. It parses a package manifest file, hopefully chases up all the references, and might just copy all the files associated with the package into a folder (or Microsoft cabinet) for your later (ab)use. This script is not well-tested: the main loop was thrown together in a couple of hours, with small changes over a few days so it didn't crash if you breathed on it wrong. It's coming along nice though in my opinion, thanks to the bug reports flowing in. It was reconstucted from a script I scribbled out last year to automate Windows RE package extraction, that I lost when I reformatted my hard disk in August 2013. It has quite a few improvements over that original, unreleased version though: Like DISM, supports the /ONLINE and /IMAGE command-line switches, for extracting packages from offline copies of Windows, or (mounted) WIMs; Something vaguely resembling error-checking; A /DEBUG switch, which the output of might help you if package extraction goes wrong; With help from my SxS File Expander tool, support for compressed SxS repositories (like in Windows 8.1); With help from the MS Cabinet Tool (CABARC.EXE, from the Internet Explorer 10 Administration Kit), support for one-command cabinet creation. It, sadly, has some horrible limitations as well, though: It's written in VBScript! So you'll have a bitch of a time integrating it into something else, or writing a GUI for it; The /IMAGE command-line switch, unlike DISM, expects the image's Windows folder to be the last path element, rather the root path of the image. Where in DISM the parameter would be (for example) /IMAGE:C:\Folder\Mount, this script expects /IMAGE:C:\Folder\Mount\Windows; A few people have had permissions problems with the script (which I'm still convinced is due to funny file ACLs). They've offered workarounds, however; No doubt dozens of other failure cases because, just like the original, it's some of the most rushed, rubbish code I've ever written. How to use it? Please find the script attached to this post. Of course, change the filename to sxsextract.vbs before trying to use it. The command-line syntax is reasonably simple (stolen from the /? switch output): Spoiler Code: Aunty Mel's Cheap And Nasty SxS Package Extractor, 2013/11/09 Copyright (C) 2012-2013 Melinda Bellemore. All rights reserved. CSCRIPT.EXE SXSEXTRACT.VBS [/?,/H,/HELP] [/DEBUG,/V] </ONLINE|/IMAGE:<folder>> [/INCLUDERES] [/VICIOUSHACKS] <source>.mum [<target>[.cab]] Parses a Windows Side-by-Side package manifest file, chases up all the references, and copies all the files associated with the package. /?,/H,/HELP Display this help text. /DEBUG,/V Enable verbose debug output. /ONLINE Uses %SYSTEMROOT% (usually C:\Windows) as the root folder to search for associated files. /IMAGE:<folder> Uses <folder> as the root folder to search for associated files instead. /INCLUDERES Extract MUI resources as well, for packages that don't have associated language packs. /VICIOUSHACKS Activates a couple of hacks to the script, for extracting 'difficult' packages that don't reference assemblies by exact name. <source>.mum Specifies a package manifest file. Wildcards are not permitted. <target>[.cab] Specifies the target folder for extracted files. If the extension '.cab' is specified, the script will call CABARC.EXE to create a cabinet of the extracted files. This script requires both SXSEXPAND.EXE and CABARC.EXE, either in the current folder or on the system PATH, for full functionality. For example: Code: D:\>cscript.exe sxsextract.vbs /online C:\Windows\servicing\Packages\Microsoft-Windows-TFTP-Client-Package~31bf3856ad364e35~x86~~6.2.9200.16384.mum Bonus n00b repellant: Copy-pasting this command, and then complaining that it doesn't work in fractured AOLspeak, will not be looked upon kindly. The people this script is intended for understand what I'm trying to demonstrate here. Remember, this script is very niche; useless to 99% of computer users. Anyway, it will churn for a moment, generating a lot of output in the process, and a new folder (with the same base name as the package) will appear in the current folder. If the Windows Deployment Image Servicing and Management tool (known as DISM to its friends) and the target operating system are amenable - and my script didn't miss any files - that folder can be used as a parameter of the /Add-Package switch to install it into Windows PE, or a lesser edition of Windows than you extracted it from, et cetera. If you want to be a huge show-off, you can compress the resulting folder - by specifying '.CAB' as the extension of the output parameter - and then pack the resulting cabinet away in (for example) your WinPE build environment. Then sit back all hoity-toity and pretend you're an OEM like Dell or HP that can afford the OEM Preinstallation Kit! The /ONLINE and /IMAGE switches should be familiar to you if you've ever used DISM, and if you haven't, this is a very good time to start. If something does go wrong (and I have no doubt it will), the script has a /DEBUG switch, which increases the verbosity of the script while it's running by a factor of five, which will (hopefully) give you some clue as to what went wrong, and put you on the path of being able to fix it: Code: D:\>cscript.exe sxsextract.vbs /debug /online C:\Windows\servicing\Packages\Microsoft-Windows-TFTP-Client-Package~31bf3856ad364e35~x86~~6.2.9200.16384.mum Another switch is /VICIOUSHACKS which, as it's name suggests, turns on the 'vicious hacks' to the script, which might help in extracting 'difficult' packages; ones that don't reference their assemblies and/or manifests by exact name - examples of these include the TFTP client, and (if I recall) Adobe Flash for Windows 8.x. For instance: Code: D:\>cscript.exe sxsextract.vbs /vicioushacks /online C:\Windows\servicing\Packages\Microsoft-Windows-TFTP-Client-Package~31bf3856ad364e35~x86~~6.2.9200.16384.mum There's one more switch: /INCLUDERES. It's only for packages that don't have associated MUI resources in another package - the vastest majority do, presented as a package with the same base name as the package you're extracting, but with "en-US" (or another language code) in the file name. Therefore, it's not a good idea to use this switch unless you know for a fact the package you're extracting needs it. KNARZ explains it here in (slightly) more detail. Sample output Spoiler Code: D:\>cscript sxsextract.vbs /vicioushacks /image:E:\Windows "E:\Windows\Servicing\Packages\WinPE-SRT-Package~31bf3856ad364e35~x86~~6.3.9600.16384.mum" WinPE-SRT.CAB <removed for length reasons. I may put it back in if there's popular demand> D:\>dir Volume in drive D is Data Volume Serial Number is BAAD-F00D Directory of D:\ 23/10/2013 12.16 7,553,183 WinPE-SRT.CAB 1 File(s) 7,923,012 bytes 0 Dir(s) 1,122,749,132,800 bytes free Support? Comments and bug reports are welcomed, often read, and sometimes even fixed. Having said that, the intended audience for this script doesn't strike me as the type to need much hand-holding. Works based upon this script are also welcomed, but please don't pretend you wrote it yourself - include an acknowledgement in the style of 'Based upon SuperBubble's SxS Package Extractor', ideally. That way, I won't have to sue you. Thanks! Hugs and snugs to murphy78, moderate and abbodi1406 for their interest in this script. I hope you find it useful. Special thanks to Stannieman and KNARZ for their keen interest and bug reports. Extra-special thanks to Mr Jinje for his GUI front-end, "Bubble's Cheap And Nasty SxS Extractor GUI", that he had a bitch of a time writing. Change log Spoiler 2013/11/09: Fixed a bug where (when not using the /INCLUDERES switch) an MUI reference in a manifest caused the script to skip the rest of the manifest, instead of only that reference; this (most famously) broke extraction of WinPE-SRT 6.3 - but it almost certainly broke other packages as well. Reported by abbodi1406. Help fix by Mr Jinje. 2013/10/24: Whoopsie... the script has never even attempted to extract drivers - until now. Reported by KNARZ. The previous version badly broke cabinet creation. Fixed. 2013/10/22: Rewritten copying routine, with considerably better error checking. It also uses the SUBST command to shorten file paths, which should help work around VBScript's path length limit of 260 characters - which is the underlying issue causing a lot of the file copying problems people were having. Based on multiple reports by KNARZ. Now attempts to copy the package in uncompressed form to the target folder/cabinet, to match Windows 8.1 package semantics, and to help tools like CBS Package Inspector. Only slightly increases cabinet sizes (WinPE-SRT.CAB was 18.5 KB larger). Suggested by KNARZ. The script will now only complain about SxS File Expander and/or MS Cabinet Tool being missing if it needs them/it for the current command. Changed 'input' and 'output' terminology to 'source' and 'target', to match my SxS File Expander tool. A teeny, tiny help fix. You guessed it - better logging and debug output. 2013/09/30: New /VICIOUSHACKS switch, which makes optional a couple of hacks to the script that have existed since Generation II. These hacks were originally devised to allow extraction of the TFTP client. The copy routines now have an error handler. This (finally!) fixes the crash reported by KNARZ, but frustratingly, doesn't solve the underlying problem, which might actually be a bug in VBScript. Stopped publishing the script pseudonymously - third-rate Google-fu will reveal my name anyway. 2013/09/28: Previous version broke the /IMAGE switch. Fixed. The script now detects whether the external tools (SxS File Expander and the MS Cabinet Tool) are available, rather than just crashing messily when trying to call them. Another attempt to fix a crash reported by KNARZ - I doubt this one worked either. Got creative with the invocation of the Cabinet Tool, to work around bugs in it's -P switch. Fixed the sanity check that ensured the script actually loaded the right manifests - in the previous version, all manifests matching the wildcard were loaded. New /INCLUDERES switch, for extracting MUI resources. It's now the default behaviour not to extract them, as the vast majority of feature packages have associated MUI packs. Returned to the default of creating a folder - rather than a cabinet - of the extracted package, because there will be users who don't have (or want) the Cabinet Tool. As per usual, better logging and debug output. 2013/09/27: Heavily recoded and refactored. New bugs have almost certainly been introduced, old bugs may have been resurrected - be warned! Now supports extraction from compressed SxS repositories (Windows 8.1, and Windows 8 with KB2821895), with help from my SxS File Expander tool. Allows one-command cabinet creation with help from the Microsoft Cabinet Tool (CABARC.EXE), which is found in the IE10 Administration Kit. Hopefully fixed a crash situation during package copy. Reported by KNARZ. Put help into the script, accessible with the /? switch. Looks much more professional now. Moved checking for existing folders and files to script startup, so you're not left waiting until the copy phase to find out a file is in the way, and needs to be deleted. Forgot to mention: now defaults to creating a cabinet of the extracted package. Better logging and debug output. 2013/09/21: The script no longer falls over if it adds the same file/folder to the copy list multiple times, hopefully enabling extraction of the Microsoft-Windows-Security-SPP-* packages. Reported by KNARZ. 2013/09/20: New 'wildcard' file matcher allows extraction of packages like Snipping Tool, which reference their MUI resources in an interesting way. Also vastly improves performance. Based on a report by Stannieman. Better unexpected situation handling - some errors are now worked around, instead of stopping the script. Abandoned 'Generation <X>' version designations, in favour of simple date-stamping. 2013/09/19 - Generation III: Fixed a typo that caused certain referenced assemblies/manifests to not be copied. Reported by Stannieman. Fixed overly-aggressive editing of the names of copied assembly folders. 2013/09/17 - Generation II: Initial release.