包含檔案與設定

指定移轉 .xml 檔案時,使用者狀態移轉工具 (USMT) 5.0 會移轉在 USMT 移轉哪些項目?中指定的設定與元件。若要包含其他檔案與設定,建議您建立自訂 .xml 檔案,然後在使用 ScanState 和 LoadState 命令時加入這個檔案。建立自訂 .xml 檔案,可以將您所做的變更與預設 .xml 檔案分開,以輕鬆追蹤您所做的修改。

在本主題中:

  • 移轉單一登錄機碼

  • 移轉特定資料夾

  • 移轉特定磁碟機中的資料夾

  • 移轉任意位置中的資料夾

  • 將檔案類型移轉至特定資料夾

  • 移轉特定檔案

移轉單一登錄機碼

下列 .xml 檔案會移轉單一登錄機碼。

<migration urlid="https://www.microsoft.com/migration/1.0/migxmlext/test">
     <component type="Application" context="System">
          <displayName>Component to migrate only registry value string</displayName> 
          <role role="Settings">
          <rules>
               <include>
                    <objectSet>
                         <pattern type="Registry">HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Cache [Persistent]</pattern> 
                    </objectSet>
               </include>
          </rules>
          </role>
     </component>
</migration>

移轉特定資料夾

下列範例會顯示如何從特定磁碟機以及電腦的任意位置移轉資料夾。

移轉特定磁碟機中的資料夾

  • **包含子資料夾。**下列 .xml 檔案會將 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 including subfolders</displayName>
      <role role="Data">
        <rules>
          <include>
            <objectSet>
              <pattern type="File">C:\EngineeringDrafts\* [*]</pattern>
            </objectSet>
          </include>
        </rules>
      </role>
    </component>
    </migration>
    
  • **排除子資料夾。**下列 .xml 檔案會移轉 C:\EngineeringDrafts 中的所有檔案,但不會移轉 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>
        </rules>
      </role>
    </component>
    </migration>
    

移轉任意位置中的資料夾

下列 .xml 檔案會從電腦的任意磁碟機中,移轉 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 folder on any drive on the computer </displayName>
  <role role="Data">
    <rules>
         <include>
            <objectSet>
         <script>MigXmlHelper.GenerateDrivePatterns ("\EngineeringDrafts\* [*] ", "Fixed")</script>            
         <script>MigXmlHelper.GenerateDrivePatterns ("*\EngineeringDrafts\* [*] ", "Fixed")</script>            
       </objectSet>
          </include>
    </rules>
  </role>
</component>
</migration>

下列 .xml 檔案會從 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 EngineeringDrafts folder from where ever it exists on the C: drive </displayName>
  <role role="Data">
    <rules>
         <include>
            <objectSet>                 
<pattern type="File"> C:\*\EngineeringDrafts\* [*]</pattern>
<pattern type="File"> C:\EngineeringDrafts\* [*]</pattern>
       </objectSet>
          </include>
    </rules>
  </role>
</component>
</migration>

將檔案類型移轉至特定資料夾

下列 .xml 檔案會將來源電腦上指定磁碟機中的 .mp3 檔案,移轉至目的電腦上的 C:\Music 資料夾。

<migration urlid="https://www.microsoft.com/migration/1.0/migxmlext/test">
<component type="Documents" context="System">
  <displayName>All .mp3 files to My Documents</displayName>
  <role role="Data">
    <rules>
      <include>
        <objectSet>
          <script>MigXmlHelper.GenerateDrivePatterns ("* [*.mp3]", "Fixed")</script>
        </objectSet>
      </include>
      <!-- Migrates all the .mp3 files in the store to the C:\Music folder during LoadState -->
      <locationModify script="MigXmlHelper.Move('C:\Music')">
        <objectSet>
          <script>MigXmlHelper.GenerateDrivePatterns ("* [*.mp3]", "Fixed")</script>
        </objectSet>
      </locationModify>
    </rules>
  </role>
</component>
</migration> 

移轉特定檔案

下列範例會顯示如何從特定資料夾以及任意位置移轉檔案。

  • **從資料夾移轉檔案。**下列 .xml 檔案只會將來源電腦上 C:\EngineeringDrafts 中的 Sample.doc 檔案移轉至目的電腦。

    <migration urlid="https://www.microsoft.com/migration/1.0/migxmlext/test">
    <component type="Documents" context="System">
      <displayName>Component to migrate all Engineering Drafts Documents</displayName>
      <role role="Data">
        <rules>
          <include>
            <objectSet>
              <pattern type="File"> C:\EngineeringDrafts\ [Sample.doc]</pattern>
            </objectSet>
          </include>
        </rules>
      </role>
    </component>
    </migration>
    
  • **從任意位置移轉檔案。**若要從 C:\ 磁碟機上的任意位置移轉 Sample.doc 檔案,請如下列範例所示使用 <pattern> 元素。如果 C:\ 磁碟機上具有多個同名的檔案,則會移轉此名稱的所有檔案。

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

    若要從電腦上的任意磁碟機移轉 Sample.doc 檔案,請如下列範例所示使用 <script>。如果具有多個同名的檔案,則會移轉此名稱的所有檔案。

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

另請參閱

其他資源

自訂 USMT XML 檔案
自訂 XML 範例
衝突與優先順序
USMT XML 參考