This project has moved and is read-only. For the latest updates, please go here.

Create a MSU import feature

Topics: Feature Request
Oct 8, 2014 at 3:18 PM
Deploying hotfixes via WSUS is something I do a lot, I'm not sure about others, but right now the process is a bit tedious and repetitive.
Something interesting is that there are detection logic and installation instructions contained within the MSU files. I'm wondering if there's some way to use those to generate the appropriate XML file for customupdatepublisher and fill in some of the metadata for the update, including the applicability and installed rules, from the information contained in the MSU file.
This is just the start of my looking into the workings of MSU files beyond just using the included CAB files with pkgmgr/dism. I wouldn't mind doing more research on this subject if it's an unknown for all involved.
Oct 8, 2014 at 5:55 PM
Do you have any documentation on MSU files ? What steps are you using now to deploy msu files ?
Nov 3, 2014 at 8:26 PM
Edited Nov 3, 2014 at 8:54 PM
I've looked for the MSU authoring documentation to see if there's a standard that they adhere to, but work and life have been keeping me from pursuing this, so no, I haven't found the documentation required to put together an automatic MSU repackager with a high level of confidence.

Here's an example of how I deploy hotfixes from my documentation, this is for KB2462317, which is applicable to the 64-bit versions of Windows Vista, 7, Server 2008, and Server 2008 R2:

Install Command:
Windows 7:
%systemroot%\system32\dism.exe /online /add-package /packagepath:.\Windows6.1-KB2462317-v2-x64.cab /quiet /norestart /logpath:%systemroot%\temp\KB2462317.log /loglevel:2
Windows Vista:
%systemroot%\system32\pkgmgr.exe /ip /m:.\Windows6.0-KB2462317-x64.cab /quiet /norestart
Installed Detection:
windows version equalto 6.0/6.1
select * from Win32_QuickFixEngineering where hotfixid = "kb2462317"

Update File:
CustomUpdateEngine.exe
Additional Files:
Windows 7:
7-x64-2880-R2-x64\kb2462317.xml
7-x64-2880-R2-x64\Windows6.1-KB2462317-v2-x64.cab
Windows Vista:
Vista-x64-2008-x64\kb2462317.xml
Vista-x64-2008-x64\Windows6.1-KB2462317-v2-x64.cab
Update Info:
Vendor Name:
Microsoft
Product Name:
Windows
Title:
Update for Windows 7 x64 and 2008 R2 x64 (KB2462317)
Update for Windows Vista x64 and Windows Server 2008 x64(KB2462317)
Description:
This hotfix fixes the following issue:
When printing to a networked XPS printer, you experience a longer time than usual to print the documents. For example, it may take from 5 to 10 minutes to print a document that usually takes 10 seconds to print. Additionally, some large spool files that are several megabytes in size are generated when the print jobs are processed.
More Info URL:
http://support.microsoft.com/kb/2462317
Package Type:
Update
Reboot Behavior:
CanRequestReboot
Return Codes:
{
  Value: 0
  Result: Succeeded
  Need Reboot: Unchecked
}
{
  Value: 3010
  Result: Succeeded
  Need Reboot: Checked
}
Command Line:
\actionfile=kb2462317.xml
Update is installed:
Windows 7 x64/Server 2008 R2 x64:
Load the rules file "installed 6.1.rules" into the Update level rules AND section
Windows Vista x64/Server 2008 x64:
Load the rules file "installed 6.0.rules" into the Update level rules AND section
Check "Delete Rules at Package Level"

Update is installable:
Windows 7 x64/Server 2008 R2 x64:
Load the rules file "installable 6.1.rules" into the Update level rules AND section
Windows Vista x64/Server 2008 x64:
Load the rules file "installable 6.0.rules" into the Update level rules AND section
Check "Delete Rules at Package Level"
Publish update and make visible in WSUS console

I extracted the files
7-x64-2880-R2-x64\Windows6.1-KB2462317-v2-x64.cab
Vista-x64-2008-x64\Windows6.1-KB2462317-v2-x64.cab
from the MSU using 7zip, but they can also be extracted using expand.

Here are the files referenced above:
7-x64-2880-R2-x64\kb2462317.xml
<CustomUpdate>
<Action>
<ElementType>CustomUpdateElements.VariableElement</ElementType>
<Name>Return Code</Name>
<Type>Int</Type>
<ID>37311fe4-0323-438d-8723-3edd6ea1c357</ID>
</Action>
<Action>
<ElementType>CustomUpdateElements.ExecutableElement</ElementType>
<PathToExecutable>%systemroot%\system32\dism.exe</PathToExecutable>
<Parameters>/online /add-package /packagepath:.\Windows6.1-KB2462317-v2-x64.cab /quiet /norestart /logpath:%systemroot%\temp\KB2462317.log /loglevel:2</Parameters>
<KillProcess>True</KillProcess>
<TimeBeforeKilling>10</TimeBeforeKilling>
<Variable>37311fe4-0323-438d-8723-3edd6ea1c357</Variable>
</Action>
<Action>
<ElementType>CustomUpdateElements.ReturnCodeElement</ElementType>
<ReturnCodeMethod>Variable</ReturnCodeMethod>
<StaticReturnCode>0</StaticReturnCode>
<Variable>37311fe4-0323-438d-8723-3edd6ea1c357</Variable>
</Action>
</CustomUpdate>
Vista-x64-2008-x64\kb2462317.xml
<CustomUpdate>
<Action>
<ElementType>CustomUpdateElements.VariableElement</ElementType>
<Name>Return Code</Name>
<Type>Int</Type>
<ID>37311fe4-0323-438d-8723-3edd6ea1c357</ID>
</Action>
<Action>
<ElementType>CustomUpdateElements.ExecutableElement</ElementType>
<PathToExecutable>%systemroot%\system32\pkgmgr.exe</PathToExecutable>
<Parameters>/ip /m:.\Windows6.0-KB2462317-x64.cab /quiet /norestart</Parameters>
<KillProcess>True</KillProcess>
<TimeBeforeKilling>10</TimeBeforeKilling>
<Variable>37311fe4-0323-438d-8723-3edd6ea1c357</Variable>
</Action>
<Action>
<ElementType>CustomUpdateElements.ReturnCodeElement</ElementType>
<ReturnCodeMethod>Variable</ReturnCodeMethod>
<StaticReturnCode>0</StaticReturnCode>
<Variable>37311fe4-0323-438d-8723-3edd6ea1c357</Variable>
</Action>
</CustomUpdate>
installable 6.0.rules
<bar:Processor Architecture="9"/><bar:WindowsVersion Comparison="EqualTo" MajorVersion="6" MinorVersion="0"/><lar:Not><bar:WmiQuery Namespace="root\CIMV2" WqlQuery="select * from Win32_QuickFixEngineering where hotfixid = &quot;kb2462317&quot;"/></lar:Not>
installable 6.1.rules
<bar:Processor Architecture="9"/><bar:WindowsVersion Comparison="EqualTo" MajorVersion="6" MinorVersion="1"/><lar:Not><bar:WmiQuery Namespace="root\CIMV2" WqlQuery="select * from Win32_QuickFixEngineering where hotfixid = &quot;kb2462317&quot;"/></lar:Not>
installed 6.0.rules
<bar:WmiQuery Namespace="root\CIMV2" WqlQuery="select * from Win32_QuickFixEngineering where hotfixid = &quot;kb2462317&quot;"/><bar:Processor Architecture="9"/><bar:WindowsVersion Comparison="EqualTo" MajorVersion="6" MinorVersion="0"/>
installed 6.1.rules
<bar:WmiQuery Namespace="root\CIMV2" WqlQuery="select * from Win32_QuickFixEngineering where hotfixid = &quot;kb2462317&quot;"/><bar:Processor Architecture="9"/><bar:WindowsVersion Comparison="EqualTo" MajorVersion="6" MinorVersion="1"/>