匯出 (0) 列印
全部展開
本主題尚未接受評分 - 為這個主題評分

XML 範例

適用於: Windows Vista

note附註
您可能需要調整左邊資訊看板的寬度,才能檢視這個主題。例如,如果需要捲動才能讀取文字,則請將資訊看板移至左邊。

本主題內容:

範例 1:移轉不受支援的應用程式

以下是您要移轉自己的應用程式時所需要的區段範本 - 它無法作用,但可以用它來撰寫自己的 .xml 檔案。

<migration urlid="http://www.microsoft.com/migration/1.0/migxmlext/migapp">
  <component type="Application">
    <!-- Name of the application -->
    <displayName>Some Application</displayName>
    <!-- Specify whether the environment variables exist in the context of user or system or both -->
    <environment context="System">
      <!-- create the environment variables -->
      <variable name="myVar1">
        <!-- simple text value assignment to a variable -->
        <text>value</text>
      </variable>
      <variable name="myAppExePath">
        <!-- make a call to in-built helper function to get a value from a reg key and assign that value to the variable -->
        <script>MigXMLHelper.GetStringContent("Registry","HKLM\Software\MyApp\Installer [EXEPATH]")</script>
      </variable>
    </environment>
    <role role="Settings">
      <detects>
        <!-- all of these checks must be true for the component to be detected -->
        <detect>
          <!-- make a call to in-built helper function to check to see if an object exists or not -->
          <condition>MigXMLHelper.DoesObjectExist("Registry","HKLM\Software\MyApp [win32_version]")</condition>
        </detect>
        <detect>
          <!-- either of these checks must be true for the component to be detected -->
          <!-- make a call to in-built helper function to check to see if a file version matches or not -->
          <condition>MigXMLHelper.DoesFileVersionMatch("%MyAppExePath%","ProductVersion","8.*")</condition>
          <condition>MigXMLHelper.DoesFileVersionMatch("%MyAppExePath%","ProductVersion","9.*")</condition>
        </detect>
      </detects>
      <!-- describe the rules that will be executed during migration of this component and the context, whether user, system or both -->
      <rules context="User">
        <!-- delete objects specified in the object set on the destination machine before applying source objects -->
        <destinationCleanup>
          <!-- describe the pattern for the list of objects to be deleted -->
          <objectSet>
            <pattern type="Registry">HKCU\Software\MyApp\Toolbar\* [*]</pattern>
            <pattern type="Registry">HKCU\Software\MyApp\ListView\* [*]</pattern>
            <pattern type="Registry">HKCU\Software\MyApp [ShowTips]</pattern>
          </objectSet>
        </destinationCleanup>
        <!-- specify which set of objects should be migrated -->
        <include>
          <!-- describe the pattern for the list of objects to be included -->
          <objectSet>
            <pattern type="Registry">HKCU\Software\MyApp\Toolbar\* [*]</pattern>
            <pattern type="Registry">HKCU\Software\MyApp\ListView\* [*]</pattern>
            <pattern type="Registry">HKCU\Software\MyApp [ShowTips]</pattern>
          </objectSet>
        </include>
        <!-- specify which set of objects should not be migrated -->
        <exclude>
          <!-- describe the pattern for the list of objects to be excluded from migration -->
          <objectSet>
            <pattern type="Registry">HKCU\Software\MyApp [Display]</pattern>
          </objectSet>
        </exclude>
      </rules>
    </role>
  </component>
</migration>

範例 2:移轉我的視訊資料夾

以下是自訂的 .xml 檔案,名為 CustomFile.xml,它會移轉所有使用者的「我的視訊」(如果來源電腦上有該資料夾存在的話)。

 

程式碼 行為
<condition>MigXmlHelper.DoesObjectExist("File","%CSIDL_MYVIDEO%")</condition>

確認來源電腦上有「我的視訊」。

<include filter='MigXmlHelper.IgnoreIrrelevantLinks()'>

將「我的視訊」中無法在目的地電腦上解析的捷徑篩選掉。這對不是捷徑的檔案沒有影響。例如,如果在來源電腦上「我的視訊」中有一個指向 C:\Folder1 的捷徑,那麼只有在目的地電腦上有 C:\Folder1 存在時才會移轉該捷徑。不過所有其他檔案 (例如 .mp3 檔案) 都會移轉,而不會進行任何篩選。

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

針對所有使用者移轉「我的視訊」。


<?xml version="1.0" encoding="UTF-8"?>
<migration urlid="http://www.microsoft.com/migration/1.0/migxmlext/CustomFile">
<component type="Documents" context="User">
        <displayName>My Video</displayName>
        <role role="Data">
            <detects>           
                <detect>
                    <condition>MigXmlHelper.DoesObjectExist("File","%CSIDL_MYVIDEO%")</condition>
                </detect>
            </detects>
            <rules>
                <include filter='MigXmlHelper.IgnoreIrrelevantLinks()'>
                    <objectSet>
                        <pattern type="File">%CSIDL_MYVIDEO%\* [*]</pattern>
                    </objectSet>
                </include>
           </rules>
        </role>
    </component>
</migration>

範例 3:移轉檔案和登錄機碼

此表格描述下列範例 .xml 檔案的行為。

 

程式碼 行為
<pattern type="File">%ProgramFiles%\USMTTestFolder\* [USMTTestFile.txt]</pattern>

從 %ProgramFiles%\USMTTestFolder 底下所有子目錄移轉 usmttestfile.txt 的所有例項。

<pattern type="File">%ProgramFiles%\USMTDIRTestFolder\* [*]</pattern>

移轉 %ProgramFiles%\USMTDIRTestFolder 下整個目錄。

<pattern type="Registry">HKCU\Software\USMTTESTKEY\* [MyKey]</pattern>

移轉 HKCU\Software\USMTTESTKEY 下 MyKey 的所有例項。

<pattern type="Registry">HKLM\Software\USMTTESTKEY\* [*]</pattern>

移轉 HKLM\Software\USMTTESTKEY 下整個登錄 Hive。


<migration urlid="http://www.microsoft.com/migration/1.0/migxmlext/testfilemig">
  <component type="Application" context="System">
   <displayName>File Migration Test</displayName>
   <role role="Data">
    <rules context="System">
     <include>
      <objectSet>
        <pattern type="File">%ProgramFiles%\USMTTestFolder\* [USMTTestFile.txt]</pattern><pattern type="File">%ProgramFiles%\USMTDIRTestFolder\* [*]</pattern>
      </objectSet>
    </include>
   </rules>
  </role>
</component>
<component type="System">
  <displayName>Registry Migration Test</displayName>
  <role role="Settings">
   <rules context="UserAndSystem">
     <include>
      <objectSet>
          <pattern type="Registry">HKCU\Software\USMTTESTKEY\* [MyKey]</pattern>
          <pattern type="Registry">HKLM\Software\USMTTESTKEY\* [*]</pattern>
      </objectSet>
     </include>
   </rules>
  </role>
 </component>
</migration>

範例 4:從各種位置移轉特定的資料夾

這個自訂 .xml 檔案的行為在程式碼的註解內描述。

<migration urlid="http://www.microsoft.com/migration/1.0/migxmlext/test">

<component type="Documents" context="System">
  <displayName>Component to migrate all Engineering Drafts subfolders without documents in this folder</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>

<component type="Documents" context="System">
  <displayName>Component to migrate all userdocuments except Sample.doc</displayName>
  <role role="Data">
    <rules>
         <include>
            <objectSet>
                 <pattern type="File"> C:\UserDocuments\* [*]</pattern>
            </objectSet>
          </include>
        <exclude>
             <objectSet>
                 <pattern type="File"> C:\UserDocuments\ [Sample.doc]</pattern>
             </objectSet>
          </exclude>
    </rules>
  </role>
</component>

<component type="Documents" context="System">
  <displayName>Component to migrate all Requests folder on any drive on the computer </displayName>
  <role role="Data">
    <rules>
         <include>
            <objectSet>
         <script>MigXmlHelper.GenerateDrivePatterns ("\Requests\* [*] ", "Fixed")</script>            
         <script>MigXmlHelper.GenerateDrivePatterns ("*\Requests\* [*] ", "Fixed")</script>            
     </objectSet>
          </include>
    </rules>
  </role>
</component>

<component type="Documents" context="System">
  <displayName>Component to migrate all Presentations folder from where ever it exists on the C: drive </displayName>
  <role role="Data">
    <rules>
         <include>
            <objectSet>                 
<pattern type="File"> C:\*\Presentations\* [*]</pattern>
<pattern type="File"> C:\Presentations\* [*]</pattern>
           </objectSet>
          </include>
    </rules>
  </role>
</component>
</migration>

本文對您有任何幫助嗎?
(剩餘 1500 個字元)
感謝您提供意見

社群新增項目

新增
顯示:
© 2014 Microsoft. 著作權所有,並保留一切權利。