How To Exclude Files and Settings

In this topic

When you specify the migration .xml files, USMT migrates the settings and components specified in What Does USMT 3.0 Migrate?. You cannot exclude users in the migration .xml files or using Config.xml. The only way to specify which users to include and exclude is on the command line using the User options. To exclude files and settings, you have the following options.

  • Modify the migration .xml files or create a custom .xml file. You can use the following elements to specify what to exclude:
    • <include> and <exclude>: You can use the <include> and <exclude> elements to exclude objects with conditions — for example, to migrate all files located in the C:\ drive, except any .mp3 files. It is important to remember that Conflicts and Precedence apply to these elements.
    • <unconditionalExclude>: You can use the <unconditionalExclude> element to globally exclude data. This element excludes objects regardless of any other <include> rules that are in the .xml files — for example, to exclude all .mp3 files on the computer or to exclude all files from C:\UserData. That is, this element takes precedence over all other include and exclude rules in the .xml files.
  • Create a Config.xml: You can create and modify a Config.xml file to exclude an entire component from the migration. For example, you can use this file to exclude the settings for one of the default applications. In addition, creating and modifying this file is the only way to exclude the operating system settings that are migrate to computers running Windows Vista. Excluding components using this file is easier than modifying the migration .xml files because you do not need to be familiar with the migration rules and syntax.
  • Additional information

Modify the migration .xml files or create a custom .xml file

We recommend that you create a custom .xml file instead of modifying the default migration .xml files. This way, you can keep your changes separate from the default .xml files and it may be easier to track your modifications. You can use the <include> and <exclude> options, and the <unconditionalExclude> option.

<include> and <exclude>

The migration .xml files (specifically MigApp.xml and MigUser.xml) contain the <component> element, which typically represents a self contained component, or an application such as Outlook and Word. To exclude the files and registry settings that are associated with these components, you should use the <include> and <exclude> elements. For example, you can use these elements to migrate all files and settings with pattern X except files and settings with pattern Y (where Y is more specific than X). For the syntax of these elements, see XML Elements Reference.

Note

If you specify <exclude>, you should always specify a corresponding <include> rule. This is because if an <include> rule is not specified, the specific files or settings will not be included anyway — that is, they will already be excluded from the migration. So an unaccompanied <exclude> rule is unnecessary.

  • Example 1: How to migrate all files from C:\ except .mp3 files
  • Example 2: How to migrate all files located in C:\Data except files in C:\Data\tmp
  • Example 3: How to exclude the files in a folder, but include all subfolders
  • Example 4: How to exclude a file from a specific folder
  • Example 5: How to exclude a file from any location

Example 1: How to migrate all files from C:\ except .mp3 files

The following .xml file migrates all files located in the C:\ drive, except any .mp3 files.

<migration urlid="https://www.microsoft.com/migration/1.0/migxmlext/mp3files">
    <!-- This component migrates all files except those with .mp3 extension-->
    <component type="Documents" context="System">
        <displayName _locID="miguser.sharedvideo">MP3 Files</displayName>
        <role role="Data">
            <rules>
                <include filter='MigXmlHelper.IgnoreIrrelevantLinks()'>
                    <objectSet>
                        <pattern type="File">C:\* [*]</pattern>
                    </objectSet>
                </include>
                <exclude>
                    <objectSet>
                        <pattern type="File">C:\* [*.mp3]</pattern>
                    </objectSet>
                </exclude>
            </rules>
        </role>
    </component>
</migration>

Example 2: How to migrate all files located in C:\Data except files in C:\Data\tmp

The following .xml file migrates all files and subfolders in C:\Data, except the files and subfolders in C:\Data\tmp.

<migration urlid="https://www.microsoft.com/migration/1.0/migxmlext/test">
    <component type="Documents" context="System">
        <displayName _locID="miguser.sharedvideo">Test component</displayName>
        <role role="Data">
            <rules>
         <include>
            <objectSet>
                 <pattern type="File">C:\Data\* [*]</pattern>
            </objectSet>
          </include>
         <exclude>
             <objectSet>
                   <pattern type="File"> C:\Data\temp\* [*]</pattern>
             </objectSet>
         </exclude>  
            </rules>
        </role>
    </component>
</migration>

Example 3: How to exclude the files in a folder, but include all subfolders

The following .xml file migrates any subfolders within C:\EngineeringDrafts, but excludes all files that are in C:\EngineeringDrafts.

<migration urlid="https://www.microsoft.com/migration/1.0/migxmlext/test">
<component type="Documents" context="System">
  <displayName>Component to migrate all Engineering Drafts Documents without subfolders</displayName>
  <role role="Data">
    <rules>
         <include>
            <objectSet>
                 <pattern type="File"> C:\EngineeringDrafts\* [*]</pattern>
            </objectSet>
          </include>
      <exclude>
        <objectSet>
          <pattern type="File"> C:\EngineeringDrafts\ [*]</pattern>
        </objectSet>
      </exclude>
    </rules>
  </role>
</component>
</migration>

Example 4: How to exclude a file from a specific folder

The following .xml file migrates all files and subfolders in C:\EngineeringDrafts, except for the Sample.doc in C:\EngineeringDrafts.

<migration urlid="https://www.microsoft.com/migration/1.0/migxmlext/test">
<component type="Documents" context="System">
  <displayName>Component to migrate all Engineering Drafts Documents except Sample.doc</displayName>
  <role role="Data">
    <rules>
         <include>
            <objectSet>
                 <pattern type="File"> C:\EngineeringDrafts\* [*]</pattern>
            </objectSet>
          </include>
      <exclude>
        <objectSet>
          <pattern type="File"> C:\EngineeringDrafts\ [Sample.doc]</pattern>
        </objectSet>
      </exclude>
    </rules>
  </role>
</component>
</migration>

Example 5: How to exclude a file from any location

To exclude Sample.doc from wherever it exists on the C: drive, use <pattern> as follows. If multiple files exist with the same name on the C: drive, then all of these files will be excluded.

<pattern type="File"> C:\* [Sample.doc] </pattern>

To exclude Sample.doc from any drive on the computer, use <script> as follows. If multiple files exist with the same name, all such files will be excluded.

<script>MigXmlHelper.GenerateDrivePatterns("* [sample.doc]", "Fixed")</script>

<unconditionalExclude>

If you want to exclude a file type from the migration, regardless of the other <include> or <exclude> rules, you can use the <unconditionalExclude> element. This element excludes objects globally across all components. For example, you should use this element if you want to exclude all .mp3 files from the computer. Or, if you are backing up C:\UserData using another method, you can exclude the entire folder from the migration. You should use this element with caution because if an application needs a file that you exclude, the application may not function properly on the destination computer. For the syntax of this element, see XML Elements Reference.

  • Example 1: How to exclude all .mp3 files
  • Example 2: How to exclude all of the files on a specific drive
  • Example 3: How to exclude registry keys
  • Example 4: How to exclude C:\Windows and C:\Program Files

Example 1: How to exclude all .mp3 files

The following .xml file excludes all .mp3 files from migration:

<migration urlid="https://www.microsoft.com/migration/1.0/migxmlext/excludefiles">
  <component context="System" type="Documents">
        <displayName>Test</displayName>
        <role role="Data">
            <rules>
             <unconditionalExclude>
                        <objectSet>
    <script>MigXmlHelper.GenerateDrivePatterns ("* [*.mp3]", "Fixed")</script>
                        </objectSet> 
             </unconditionalExclude>
            </rules>
        </role>
    </component>
</migration>

Example 2: How to exclude all of the files on a specific drive

The following .xml file excludes only the files located on the C: drive.

<migration urlid="https://www.microsoft.com/migration/1.0/migxmlext/allfiles">
    <component type="Documents" context="System">
        <displayName>Test</displayName>
        <role role="Data">
            <rules>
  <unconditionalExclude>
                    <objectSet>
      <pattern type="File">c:\*[*]</pattern>
                    </objectSet>
  </unconditionalExclude>
            </rules>
        </role>
    </component>
</migration>

Example 3: How to exclude registry keys

This is an .xml file that unconditionally excludes the HKey_Current_User registry key and all subkeys.

<?xml version="1.0" encoding="UTF-8"?>
<migration urlid="https://www.microsoft.com/migration/1.0/migxmlext/miguser">
   <component type="Documents" context="User">
      <displayName>Test</displayName>
      <role role="Data">
         <rules>
            <include>
               <objectSet>
                  <pattern type="Registry">HKCU\testReg[*]</pattern>
               </objectSet>
            </include>
            <unconditionalExclude>
               <objectSet>
                  <pattern type="Registry">HKCU\*[*]</pattern>
               </objectSet>
            </unconditionalExclude>
         </rules>
      </role>
   </component>
</migration>

Example 4: How to exclude C:\Windows and C:\Program Files

This is an .xml file that unconditionally excludes the system folders of C:\Windows and C:\Program Files. Note that all *.doc, *.xls and *.ppt files will not be migrated because <unconditionalExclude> takes precedence over <include>.

<?xml version="1.0" encoding="UTF-8"?>
<migration urlid="https://www.microsoft.com/migration/1.0/migxmlext/miguser">
   <component type="Documents" context="System">
      <displayName>Test</displayName>
      <role role="Data">
         <rules>
            <include>
               <objectSet>
    <script>MigXmlHelper.GenerateDrivePatterns ("* [*.doc]", "Fixed")</script>
    <script>MigXmlHelper.GenerateDrivePatterns ("* [*.xls]", "Fixed")</script>
    <script>MigXmlHelper.GenerateDrivePatterns ("* [*.ppt]", "Fixed")</script>
               </objectSet>
            </include>
            <unconditionalExclude>
               <objectSet>
                  <pattern type="File">C:\Program Files\* [*]</pattern>
<pattern type="File">C:\Windows\* [*]</pattern>
               </objectSet>
            </unconditionalExclude>
         </rules>
      </role>
   </component>
</migration>

Create a Config.xml file

You can create and modify a Config.xml file if you want to exclude components from the migration. For example, you can use this file to exclude the settings for one of the default applications. In addition, creating and modifying this file is the only way to exclude the operating system settings that are migrate to computers running Windows Vista. Excluding components using this file is easier than modifying the migration .xml files because you do not need to be familiar with the migration rules and syntax.

  • To exclude the settings for a default application: Specify migrate="no" for the application under the <Applications> section of this file. For example, USMT will not migrate Adobe Acrobat Reader 6.0 or Outlook 2003 in the Sample Config.xml file.
  • To exclude an operating system setting: Specify migrate="no" for the setting under the <WindowsComponents> section. For example, USMT will not migrate the user's Favorites in the Sample Config.xml file.
  • To exclude My Documents: Specify migrate="no" for My Documents under the <Documents> section. For example, see the Sample Config.xml file. Note that any <include> rules in the .xml files will still apply. For example, if you have a rule that includes all the .doc files in My Documents, then only the .doc files will be migrated, but the rest of the files will not.

Additional information