カスタム XML の例

  

このトピックの表は幅が広いので、ウィンドウの幅の調整が必要な場合があります。

 

このトピックの内容:

  • 例 1: サポートされていないアプリケーションの移行

  • 例 2: マイ ビデオ フォルダーの移行

  • 例 3: ファイルとレジストリ キーの移行

  • 例 4: さまざまな場所の特定のフォルダーの移行

例 1: サポートされていないアプリケーションの移行

以下に、アプリケーションの移行に必要なセクションのテンプレートを示します。このテンプレートはそのままでは機能しませんが、独自の .xml ファイルを記述するために使うことができます。

<migration urlid="https://www.microsoft.com/migration/1.0/migxmlext/migtestapp">
  <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 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 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 computer 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: マイ ビデオ フォルダーの移行

以下に、すべてのユーザーのマイ ビデオを移行する、CustomFile.xml という名前のカスタム .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="https://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 の下のレジストリ ハイブ全体を移行します。

 

<migration urlid="https://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 ファイルの動作は、コードの <displayName> タグ内に記述されています。

<migration urlid="https://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 user documents 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 folders 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 any location 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>

関連トピック

USMT XML リファレンス

USMT XML ファイルのカスタマイズ