Updated: 2008-06-23

Administrators use the Office Customization Tool (OCT) to customize an installation of the 2007 Microsoft Office system. The customizations are saved in a Setup customization file (MSP file) that uses Extensible Markup Language (XML) format. This article provides a sample Microsoft Visual Basic script that administrators can use to view the settings stored in OCT MSP files.

Windows Script Host overview

To run the script, use Microsoft Windows Script Host (WSH), a language-independent scripting host for Windows Script-compatible scripting engines. WSH allows you to run scripts from both the Windows desktop and the command prompt.

To run scripts from Windows, WScript.exe provides a Windows-based dialog box for setting script properties. To run scripts from the command prompt, CScript.exe provides command-line switches for setting script properties.

WSH provides drag-and-drop support for scripts. This means that you can drag files onto a WSH script. The file names are translated into arguments on the command line.

For more information about WSH, see the following resources on MSDN Web site:

ExtractOctXml.vbs script sample

The following sections provide a sample Visual Basic script, ExtractOctXml.vbs, and instructions for using the script to extract XML metadata from OCT MSP customization files.

To save the script sample, open a text editor such as Notepad, and copy and paste the script code in this section to a file. Save the script file as ExtractOctXml.vbs.

  CopyCode imageCopy Code
' Utility to extract the metadata from an Office 2007 customization patch 
' For use with Windows Scripting Host, CScript.exe or WScript.exe
' Copyright (c) Microsoft Corporation. All rights reserved.
'
Option Explicit

Const msiOpenDatabaseModePatchFile = 32
Const msiOpenDatabaseModeReadOnly	 = 0
Const msiReadStreamBytes = 1

Const ForWriting = 2
Const TristateTrue = -1

Dim pathOCT_Patch 'As String
Dim pathMetadataXml 'As String
Dim sMetadata 'As String
Dim wshShell 'As Wscript.Shell
Dim fso 'As FileSystemObject
Dim fileOutput 'As File
Dim sErrSection ' As String


sErrSection = "ArgCheck"
' Check arg count, and display help if argument not present or contains ?
Dim argCount:argCount = Wscript.Arguments.Count
If argCount > 0 Then If InStr(1, Wscript.Arguments(0), "?", vbTextCompare) > 0 Then argCount = 0
If (argCount = 0) Then
	Wscript.Echo "Office 2007 OCT Metadata Extract utility" & _
		vbNewLine & " You must supply the location of the Office 2007 customization patch " & _
		vbNewLine & _
		vbNewLine & "Copyright (C) Microsoft Corporation.  All rights reserved."
	Wscript.Quit 1
Else
	pathOCT_Patch = Trim(Wscript.Arguments(0))
End If


sErrSection = "FSO"
' Create FileSystemObject and verify file exists
Set fso = CreateObject("Scripting.FileSystemObject") : CheckError
If Not fso.FileExists(pathOCT_Patch) Then Err = 2 : CheckError


sErrSection = "WI"
' Connect to Windows Installer object
On Error Resume Next
Dim wi : Set wi = Nothing
Set wi = Wscript.CreateObject("WindowsInstaller.Installer") : CheckError


sErrSection = "Read Metadata"
' Open OCT patch and read the metadata stream
Dim wiStorage, vw, rec
Set wiStorage = wi.OpenDatabase(pathOCT_Patch, msiOpenDatabaseModePatchFile) : CheckError
Set vw = wiStorage.OpenView("SELECT * FROM _Streams WHERE `Name`='metadata' ") : CheckError
vw.Execute
Set rec = vw.Fetch
If Not rec Is Nothing Then
	sMetadata = rec.ReadStream(2, rec.DataSize(2), msiReadStreamBytes)
Else
	Wscript.Echo "No Metadata stream was found in this file: " & pathOCT_Patch
	Wscript.Quit 2
End If

Set wiStorage = Nothing
Set rec = Nothing: Set vw = Nothing
Set wi = Nothing


sErrSection = "Write Metadata"
' Write the metadata stream to a temp file
Set wshShell = CreateObject("WScript.Shell") : CheckError
pathMetadataXml = wshShell.ExpandEnvironmentStrings("%temp%") & "\" & fso.GetFileName(pathOCT_Patch) & ".xml"
Set fileOutput = fso.OpenTextFile(pathMetadataXml, ForWriting, True, -1) : CheckError
fileOutput.WriteLine sMetadata 
fileOutput.Close

Set fileOutput = Nothing: Set fso = Nothing

sErrSection = "Show Metadata"
' Launch Metadata in IE
wshShell.Run "iexplore.exe " & pathMetadataXml 



Sub CheckError
Dim sMsg, errRec
	If Err = 0 Then Exit Sub
	sMsg = sErrSection & vbNewLine & Err.Source & " " & Hex(Err) & ": " & Err.Description
	If Not wi Is Nothing Then
	Set errRec = wi.LastErrorRecord
		If Not errRec Is Nothing Then sMsg = sMsg & vbNewLine & errRec.FormatText
	End If
	Wscript.Echo sMsg
	Wscript.Quit 2
End Sub

Sub NoMetadata
End Sub

Running the script

The ExtractOctXml.vbs file can be stored anywhere on your computer. To use the ExtractOctXml.vbs script, you can simply drag the OCT MSP customization file and drop it on the script. The script extracts the metadata XML into the user's Temp folder as <name of the OCT patch>.xml. The XML file is then passed to Internet Explorer for viewing.

Run the script

  1. Use Windows Explorer to open the folder that contains the ExtractOctXml.vbs file.

  2. Drag and drop a copy of the MSP file you want to view onto the ExtractOctXml.vbs that is displayed in the Windows Explorer window.

  3. After the XML file opens, you can expand and collapse the various sections to view the settings contained in the MSP customization file.

    The <UserSettings> element of the metadata.xml file contains the user settings configured in the MSP customization file, and the <Options> element of the metadata.xml file contains settings related to feature states.

Run the script by using the command line

  1. Click Start, click Run, and then type cmd.

  2. In the command window, type:

    cscript <script path> \ExtractOCTXml.vbs <OCT MSP path and file name>

    -or-

    wscript <script path> \ExtractOCTXml.vbs <OCT MSP path and file name>

    The XML file is loaded in Internet Explorer for viewing.

Viewing the XML contents from an MSP customization file

The OCT uses settings (OPA) files to populate the Modify user settings user interface in the OCT and add the appropriate registry keys and values during the installation. Office 2007 settings OPA files are stored in the Admin folder that is located at the root of your Office 2007 source file location or CD.

The following table describes the top-level sections included in the MSP metadata.xml file.

Section Description

<Customization baseFolder>

Provides the MSP customization file name and path information. These elements are used internally by the code; they do not represent the actual customizations.

<Product id>

Provides information about the local installation source packages, installation state (such as Always installed), language MUI packages, product IDs, features and IDs, shortcuts, and upgradeable applications.

These elements are used internally by the code; they do not represent the actual customizations.

<SecurityApps>

Lists the applications that can have specific security locations as indicated in the drop-down list found in the Setup\Office Security settingsAdd the following paths to theTrusted Locations list area in the OCT.

These elements are used internally by the code; they do not represent the actual customizations.

<SecurityAppSettings>

Lists the security settings that appear in the Setup\Office Security settings area in the OCT. Customizations to this list appear in the later <SecuritySettings> element.

These elements are used internally by the code; they do not represent the actual customizations.

<SecurityPossibleSettingValues>

Lists the security options that are available for <SecurityAppSettings>.

These elements are used internally by the code; they do not represent the actual customizations.

<GlobalSettings>

Provides information about setup properties found in the Setup\Modify Setup properties section of the OCT.

<UserSettings>

Provides information and registry key data about any settings configured in the Features\Modify user settings section of the OCT.

<File>

Provides information about any files added or removed by using the Additional content\Add files or Remove files options in the OCT.

<Registry>

Provides information about any registry keys added or removed by using the Additional content\Add registry entries or Remove registry entries options in the OCT.

<Shortcuts>

Provides information about shortcuts added by using the Additional content\Configure shortcuts options in the OCT.

<Install>

Provides information about the installation settings found in the Setup\Install location and organization name, Setup\Additional network sources, and Setup\Licensing and user interface options in the OCT.

<ChildInstalls>

Provides information about additional post-installation actions found in the Setup/Add installations and run programs options in the OCT.

<Options>

Contains settings related to application feature states.

<SecuritySettings>

Provides information about changes made to the default security settings by using the Setup\Office security sections\Default security settings section of the OCT.

<SecurityTrustedLocations>

Provides information about Trusted locations added in the Setup\Office security settings options in the OCT (in the Add the following paths to the Trusted Locations list).

<SecurityCertificates>

Provides information about certificates added in the Setup\Office security settings options in the OCT (in the Add the following digital certificates to the Trusted Publishers list).

<Outlook>

Provides information about Outlook profile customization made in the Outlook options of the OCT.

The following example illustrates how to locate settings in the resulting XML file that opens in Internet Explorer when you run the ExtractOctXml.vbs script with an OCT MSP customization file.

Example

This example uses a Microsoft Office Professional 2007 Plus MSP customization file. Only Microsoft Office Access 2007 is installed and the default file format for Access, Access 2007, is configured. The Default file format user setting for Access is located in the Microsoft Office Access 2007\Miscellaneous node of the Modify user settings screen in the OCT.

Use a text editor such as Notepad to open the Access 2007 OPA settings file, access12.opa (located at the root of your Office 2007 source file location, in the Admin folder). Search for the string displayed in the OCT for the Default file format user setting, Default file format. Doing so will show the following section of the access12.opa file:

KEYNAME Software\Microsoft\Office\12.0\Access\Settings

PART !!L_Empty DROPDOWNLIST

VALUENAME "Default File Format"

ITEMLIST

NAME !!L_Access2007 VALUE NUMERIC 12 DEFAULT

NAME !!L_Access20022003 VALUE NUMERIC 10

END ITEMLIST

From this user setting information, you can determine the registry key for the setting (Software\Microsoft\Office\12.0\Access\Settings in this case) and the possible registry values. A Default File Format value of 12 sets the default file format to Access 2007, while a Default File Format of 10 sets the default file format to Access 2002-2003.

After you obtain this information from the access12.opa file, you can search the customization metadata.xml file for the registry key or value that you are looking for, such as Software\Microsoft\Office\12.0\Access\Settings. Doing so in this example would bring you to the following section of the metadata.xml file:

<AddRegistries>

<AddRegistry root="HKCU" key="Software\Microsoft\Office\12.0\Access\Settings" name="Default File Format" emptykey="false" flags="0" type="0" value="12" guid="{2A044E97-7BB1-4644-BF84-A35A5B2E5D51}" />

Using the information from the OPA file, you can see that the Default File Format key has a value of 12, which sets the default file format to Access 2007.

The following is an excerpt of what the <Options> section of the XML file looks like in this example:

<Option id="ACCESSFiles" installState="3" />

<Option id="Access_PIA" installState="3" />

<Option id="AccessWizards" installState="3" />

<Option id="CalendarControl" installState="3" />

<Option id="DeveloperWizards" installState="3" />

<Option id="AccessHelpFiles" installState="3" />

<Option id="AccessTemplatesIntl" installState="3" />

<Option id="EXCELFiles" installState="1" />

.

.

<Option id="OUTLOOKFiles" installState="1" />

.

.

<Option id="PPTFiles" installState="1" />

For more information about OptionState IDs, see the OptionState Element section of the Config.xml file in the 2007 Office system article.

See Also