How To – Exclude Files – USMT 4.0

Something I’ve seen many forum posts of is people complaining “Exclude” and “UnconditionalExclude” rules don’t work as expected in in USMT’s scanstate.exe command. The answer is simply found by spending a couple of days reverse engineering scanstate.exe into 80×86 assembly, manually converting that to C code, then re-writing your own version from scratch to exclude the files you need. Or if that seems like a waste of time you might find the answer in the USMT help file under “Conflicts and Precedence”:

  • If there are conflicting rules within a component, the most specific rule is applied. However, the <unconditionalExclude> rule is an exception because it takes precedence over all others. Directory names take precedence over file extensions.
  • Only rules inside the same component can affect each other, depending on specificity. Rules that are in different components do not affect each other, except for the <unconditionalExclude> rule.
  • If the rules are equally specific, <exclude> takes precedence over <include>. For example, if you use the <exclude> rule to exclude a file and use the <include> rule to include the same file, the file will be excluded.
  • The ordering of components does not matter.It does not matter which components are listed in which .xml file, because each component is processed independently of the other components across all of the .xml files.
  • The ordering of the <include> and <exclude> rules within a component does not matter.
  • 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, you can use the <unconditionalExclude> element to exclude all MP3 files on the computer or to exclude all files from C:\UserData.

To explain in other words:

  • You can use as many Excludes or Unconditional Excludes as you like, but if you have another <rules> section in another <component> section or additional rules in the same component under a different context i.e. User & System which <include>s the file, it will still get included. This could be in any of the .xml files you pass to scan state. So if your CustomMig.xml file that you made EXCLUDED Downloads directory, but MigUser.xml included it, you would still get the downloads folder migrated.
  • You can think of it as each time a registry or file is scanned on the system each <rules> section is checked – if any <rules> section gives it a positive match it will be included.

So in this sample custom XML file some important points:

  • In the “User Data Rule” rule we “include” the profile and “exclude” user specific settings. Remember “exclude” only applies to what is “included” within the same rule
  • In the “System Data Rule” we “exclude” the profile folder. If we had not done this, the excludes in “User Data” would have been ignored (assuming profile on C: drive) due to System Data rules’ “C:\* [*] inclusion

<?xml version=1.0 encoding=utf-8?>

<migration urlid=>

  <component type=Documents context=UserAndSystem defaultSupported=Yes>

    <displayName>User Migration</displayName>

      <role role=Data>

        <rules name=User Data context=User>

          <include filter=MigXmlHelper.IgnoreIrrelevantLinks()>


              <pattern type=File>%CSIDL_PROFILE%\* [*]</pattern>





              <pattern type=File>%TEMP%\* [*]</pattern>

              <pattern type=File>%CSIDL_INTERNET_CACHE%\* [*]</pattern>




        <rules name=System Data context=System>

          <include filter=MigXmlHelper.IgnoreIrrelevantLinks()>


              <pattern type=File>C:\* [*]</pattern>





              <pattern type=File>%PROFILESFOLDER%\* [*]</pattern>








To summarize – before using USMT 4.0 strongly recommend reading through the documentation Smile

About chentiangemalc

specializes in end-user computing technologies. disclaimer 1) use at your own risk. test any solution in your environment. if you do not understand the impact/consequences of what you're doing please stop, and ask advice from somebody who does. 2) views are my own at the time of posting and do not necessarily represent my current view or the view of my employer and family members/relatives. 3) over the years Microsoft/Citrix/VMWare have given me a few free shirts, pens, paper notebooks/etc. despite these gifts i will try to remain unbiased.
This entry was posted in Migration, USMT, Windows 7 and tagged . Bookmark the permalink.

12 Responses to How To – Exclude Files – USMT 4.0

  1. Sadiq says:

    IS there anyway to exclude drive D from being back up and restore while MDT LTI.?
    I have PCs with Xp on C drive and users other files on drive D. (The profile is in C drive only). Deployment takes a long time to scan and restore data from both C and D. If i can exclude the Drive D , i am sure i can save a lot of time.

    • Yes, this can be done easily. What are your current settings for USMT, as found in CustomSettings.ini

      • Sadiq says:


        LoadStateArgs=/lac /v:13



        I want to know what other changes do i need to put in the MDT, I have tried the following in the config.xml file in




        But this doesnt work. Please help..Appreciated..

      • I think the issue is not USMT. If you are using MigUser.Xml + MigApp.Xml the D: drive won’t be backed up unless user profile folders are redirected to D: drive.

        In addition you have set type to ‘AUTO’ which is hard-link migration, which is very fast, even if both C & D are used.

        The problem is

        should be


  2. Sadiq says:

    SkipComputerBackup=Yes will only skip the wizard prompt and will still capture the image using imagex. Even Hardlink takes around one hour to capture data (arooung 40GB) and i can see MININT folder in both C and D despite of the different settings i have made.

    • If it is taking that long it is not hard link migratinon. I am migrating 500 GB diskswith 300 GB + data\ C:& D: and USMT Hard link is taking < 10 mins for capture. Disable the comptuer backup in the task sequence. If you see D:\ minint what is the contents of the D:\minint after backup/capture user state has run.

  3. Sadiq says:

    There is no user profile specific data in D.

  4. Sadiq says:

    The content in D:\minint is the same data is the the D drive and it stays even after restoring the data in the D drive (so duplicating)

    • Have you confirmed you have disabled computer backup in task sequence?

      Is there a WIM in this d:\minint folder

      hard link migration doesn’t duplicate data, these files are just pointers to the actual files.

      I will send you an email later with more detail I require, but almost certain the long time is backup not USMT. USMT is only slow if using MigDocs.xml or backup to network/external drive.

  5. Sadiq says:

    Do i need to mention the hardlink in the command prompt ? if needed where is the command to be includes ,in which file ? I have not changed anything from the default MDT settings apart from the cs.ini. Still i can see it is doing the backup to the same hard drives partition. Where can i see the Hardlink and /local only options?

  6. Pingback: USMT – Exclude tag does not work « Allt om deployment

  7. Richard says:

    If we save the this piece of code as xml , and try to open in IE , it just shows a blank page- Wrong code.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s