重設檔案和設定的路徑

若要重設檔案和設定的路徑,請建立自訂 .xml 檔案,並同時在 ScanState 和 LoadState 命令列上指定此檔案名稱。 這樣可將您所做的變更與預設 .xml 檔案分開,以輕鬆追蹤您所做的修改。

在本主題中:

  • 重設資料夾的路徑

  • 重設特定的檔案類型路徑

  • 重設特定的檔案路徑

重設資料夾的路徑

下列自訂 .xml 檔案會將 C:\EngineeringDrafts 中的目錄和檔案移轉至每一個使用者的 [我的文件] 資料夾。%CSIDL_PERSONAL% 是虛擬資料夾,代表 [我的文件] 桌面項目,相當於 CSIDL_MYDOCUMENTS。

<migration urlid="https://www.microsoft.com/migration/1.0/migxmlext/test">
<component type="Documents" context="User">
  <displayName>Engineering Drafts Documents to Personal Folder</displayName>
  <role role="Data">
    <rules>
      <!-- Migrate all directories and files present in c:\EngineeringDrafts folder -->
      <include>
        <objectSet>
          <pattern type="File">C:\EngineeringDrafts\* [*]</pattern>
        </objectSet>
      </include>
      <!-- This migrates all files and directories from C:\EngineeringDrafts to every user’s personal folder.-->
      <locationModify script="MigXmlHelper.RelativeMove('C:\EngineeringDrafts','%CSIDL_PERSONAL%')">
        <objectSet>
          <pattern type="File">C:\EngineeringDrafts\* [*]</pattern>
        </objectSet>
      </locationModify>
    </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 檔案移轉至每一個使用者的 [我的文件] 資料夾。%CSIDL_PERSONAL% 是虛擬資料夾,代表 [我的文件] 桌面項目,相當於 CSIDL_MYDOCUMENTS。

<migration urlid="https://www.microsoft.com/migration/1.0/migxmlext/test">
<component type="Documents" context="User">
<displayName>Sample.doc into My Documents</displayName>
    <role role="Data">
      <rules>
        <include> 
          <objectSet>     
                 <pattern type="File"> C:\EngineeringDrafts\ [Sample.doc]</pattern>
          </objectSet>
        </include>
       <locationModify script="MigXmlHelper.RelativeMove('C:\EngineeringDrafts','%CSIDL_PERSONAL%')">
        <objectSet>
                 <pattern type="File"> C:\EngineeringDrafts\ [Sample.doc]</pattern>
        </objectSet>
       </locationModify>
      </rules>
    </role>
</component>
</migration>

另請參閱

其他資源

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