View Office Customization Tool output in Office 2010

 

Si applica a: Office 2010

Ultima modifica dell'argomento: 2015-03-09

You can view the custom settings that are saved in a Setup customization file (.msp file) by using a Microsoft Visual Basic script.

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

In this article:

  • Windows Script Host overview

  • ExtractOctXml.vbs script sample

  • Running the script

  • Viewing the XML contents from an .msp customization file

Windows Script Host overview

To run the script, use Windows Script Host (WSH), a language-independent scripting host for Windows Script-compatible scripting engines. WSH lets you 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.

' Utility to extract the metadata from an Office 2010 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 2010 OCT Metadata Extract utility" & _
        vbNewLine & " You must supply the location of the Office 2010 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 drag the OCT .msp customization file for which you want to see the configured settings and drop it on the script. The script extracts the metadata XML into the user's Temp folder as <name of the OCT update>.xml (for example, Access.MSP.xml). The XML file is then passed to Internet Explorer for viewing.

To 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 Setup customization .msp file that 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 Access.MSP.xml metadata.xml file contains the user settings configured in the .msp customization file, and the <Options> element of the Access.MSP.xml metadata.xml file contains settings related to feature states.

To run the script by using the command line

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

  2. In the Command Prompt 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 (.opax) files to populate the Modify user settings user interface in the OCT and add the appropriate registry keys and values during the installation. Office 2010 settings .opax files are stored in the Admin folder that is located at the root of your Office 2010 source file location or CD.

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

Section Description

<Customization platform - 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 settings Add the following paths to the Trusted 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 are 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 that were 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 shows how to locate settings in the resulting XML file (Access.MSP.xml in this example) that opens in Internet Explorer when you run the ExtractOctXml.vbs script with an OCT .msp customization file.

Example

This example uses an Office 2010 .msp customization file. Only Microsoft Access 2010 is installed and the Microsoft Office Access 2007 file format is enabled. The Default file format user setting for Access is located in the Microsoft Office Access 2010\Miscellaneous node of the Modify user settings section of the OCT.

You can search the customization metadata.xml file, Access.MSP.xml, for the registry key or value, such as Default file format. Searching for “default file format” in this example would bring you to the following section of the Access.MSP.xml metadata.xml file:

<AddRegistries>

<AddRegistry root="HKCU" key="software\microsoft\office\14.0\access\settings" name="default file format" emptykey="false" flags="0" type="2" value="12" guid="{39478C45-8DBA-403C-B4BB-1F1D07CE85D7}" />

Use a text editor, such as Notepad, to open the Access 2010 .opax settings file, access14.opax (located at the root of your Office 2010 source file location, in the Admin folder). Search for the DefaultFileFormat string (which corresponds to the Default file format user setting). Doing so will show the following section of the access14.opax file:

<policy name="L_DefaultFileFormat" class="User" displayName="$(string.L_DefaultFileFormat)" explainText="$(string.L_DefaultFileFormatExplain)" presentation="$(presentation.L_DefaultFileFormat)" key="software\policies\microsoft\office\14.0\access\settings">

<parentCategory ref="L_Miscellaneous" />

<supportedOn ref="windows:SUPPORTED_WindowsVista" />

<elements>

<enum id="L_empty87" valueName="Default File Format">

<item displayName="$(string.L_Access2007)">

<value>

<decimal value="12" />

</value>

</item>

<item displayName="$(string.L_Access20022003)">

<value>

<decimal value="10" />

</value>

</item>

<item displayName="$(string.L_Access2000)">

<value>

<decimal value="9" />

</value>

</item>

</enum>

</elements>

</policy>

From this user setting information, you can determine the registry key for the setting (software\policies\microsoft\office\14.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.

Using the information from the .opax 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 excerpts show some of the Access Option id values that are listed in the <Options> section of the Access.MSP.xml file in this example:

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

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

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

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

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

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

For more information about OptionState IDs, see OptionState element in Config.xml file in Office 2010.