How can I migrate registry keys from one location on the source to another on the destination

if you want to migrate registry keys from one location to another
(provided that they are detected) then use the following code in a
custom XML file

<?xml version="1.0" encoding="UTF-8"?><migrationurlid="http://www.microsoft.com/migration/1.0/migxmlext/WNB_move_reg_keys"><!-- WNB_move_reg_keys.xml is basically a customized version of MigUser.xml --><_locDefinition>  <_locDefault _loc="locNone"></_locDefault>  <_locTag _loc="locData">displayName</_locTag></_locDefinition> <!-- This component migrates Old Reg Keys and moves them to NEW locations provided that the key exists --><componentcontext="User"type="Application">  <displayName _locID="regkeymove_user">Move old reg keys to new location</displayName>  <rolerole="Settings">   <detects>        <detect>        <condition>MigXmlHelper.DoesObjectExist("Registry","HKLM\SOFTWARE\CUSTOM [CUSTOMval#1]")</condition>        </detect>   </detects>   <rules>        <include>        <objectSet>        <patterntype="Registry">HKLM\SOFTWARE\CUSTOM [CUSTOMval#1]</pattern>        <patterntype="Registry">HKLM\SOFTWARE\CUSTOM [CUSTOMval#2]</pattern>        </objectSet>        </include>        <locationModifyscript="MigXmlHelper.ExactMove('HKLM\SOFTWARE\CUSTOM [PrevCUSTOMval#1]')">        <objectSet>        <patterntype="Registry">HKLM\SOFTWARE\CUSTOM [CUSTOMval#1]</pattern>        </objectSet>        </locationModify>        <locationModifyscript="MigXmlHelper.ExactMove('HKLM\SOFTWARE\CUSTOM [PrevCUSTOMval#2]')">        <objectSet>        <patterntype="Registry">HKLM\SOFTWARE\CUSTOM [CUSTOMval#2]</pattern>        </objectSet>        </locationModify>   </rules>  </role></component></migration>

this code checks if the following registry key exists HKLM\SOFTWARE\CUSTOM\CUSTOMval#1 and if it does, it migrates the following two registry keys from the SOURCE pc

HKLM\SOFTWARE\CUSTOM\CUSTOMval#1
HKLM\SOFTWARE\CUSTOM\CUSTOMval#2

to the following locations on the DESTINATION pc

HKLM\SOFTWARE\CUSTOM\PrevCUSTOMval#1
HKLM\SOFTWARE\CUSTOM\PrevCUSTOMval#2

Note: if you are using a 64 bit OS with a 32bit application (X86) that you’ll probably want to change the path statements

for example, change

HKLM\SOFTWARE\CUSTOM [CUSTOMval#1]  

to

HKLM\SOFTWARE\Wow6432Node\CUSTOM\[CUSTOMval#1]

cheers
niall

This entry was posted in Uncategorized. Bookmark the permalink.

3 Responses to How can I migrate registry keys from one location on the source to another on the destination

  1. Alex says:

    Hi,

    I have modified your script to copy the defaultusername key from the registry, but for some reason when I check the target windows 7 machine after the task sequence has finished the entry for defaultusername is blank.

    Here is the modifed script:

    displayName

    Move old reg keys to new location

    MigXmlHelper.DoesObjectExist(“Registry”,”HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName [CUSTOMval#1]”)

    HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName [CUSTOMval#1]

    HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName [CUSTOMval#1]

    Do you have any ideas why this is failing to copy the key to the windows 7 machine ?

    Thanks in advance,

    Alex.

  2. Alex says:

    Sorry for some reason the script did not copy correctly

    displayName

    Move old reg keys to new location

    MigXmlHelper.DoesObjectExist(“Registry”,”HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName [CUSTOMval#1]”)

    HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName [CUSTOMval#1]

    HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName [CUSTOMval#1]

  3. djub says:

    Nice but how do i execute the it.

    Thks in advance.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.