Exemples XML personnalisés

Exemple 1 : Migration d’une application non prise en charge

Le modèle suivant est un modèle pour les sections nécessaires à la migration des applications. Le modèle n’est pas fonctionnel en soi, mais il peut être utilisé pour écrire un fichier .xml personnalisé.

Modèle

Développez pour afficher l’exemple 1 de modèle d’application :
<migration urlid="http://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>

Exemple 2 : Migration du dossier Mes vidéos

L’exemple suivant est un fichier .xml personnalisé nommé CustomFile.xml qui migre le dossier Vidéos pour tous les utilisateurs, si le dossier existe sur l’ordinateur source.

  • Exemple de condition : vérifie que le dossier Vidéos existe sur l’ordinateur source :

    <condition>MigXmlHelper.DoesObjectExist("File","%CSIDL_MYVIDEO%")</condition>

  • Exemple de filtre : filtre les raccourcis du dossier Vidéos qui ne sont pas résolus sur l’ordinateur de destination :

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

    Ce filtre n’a aucun effet sur les fichiers qui ne sont pas des raccourcis. Par exemple, s’il existe un raccourci dans le dossier Vidéos sur l’ordinateur source qui pointe vers C:\Folder1, ce raccourci est migré uniquement s’il C:\Folder1 existe sur l’ordinateur de destination. Toutefois, tous les autres fichiers, tels que les fichiers.mp3 , migrent sans aucun filtrage.

  • Exemple de modèle : migre le dossier Vidéos pour tous les utilisateurs :

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

Fichier XML

Développez pour afficher l’exemple de fichier XML 2 :
<?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>

Exemple 3 : Migration de fichiers et de clés de Registre

Les exemples de modèles décrivent le comportement dans l’exemple .xml fichier suivant.

  • Exemple de modèle : migre toutes les instances du fichier Usmttestfile.txt à partir de tous les sous-répertoires sous %ProgramFiles%\USMTTestFolder:

    <pattern type="File">%ProgramFiles%\USMTTestFolder* [USMTTestFile.txt]</pattern>

  • Exemple de modèle : migre l’ensemble du répertoire sous %ProgramFiles%\USMTDIRTestFolder:

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

  • Exemple de modèle : migre toutes les instances de MyKey sous HKCU\Software\USMTTESTKEY:

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

  • Exemple de modèle : migre l’intégralité de la ruche du Registre sous HKLM\Software\USMTTESTKEY:

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

Fichier XML

Développez pour afficher l’exemple de fichier XML 3 :
<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>

Exemple 4 : Migration de dossiers spécifiques à partir de différents emplacements

Le comportement de ce fichier .xml personnalisé est décrit dans les <displayName> balises du code.

Fichier XML

Développez pour afficher l’exemple de fichier XML 4 :
<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 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>