3

I am migrating from Windows XP to Windows 7. I use database software (Aginity Workbench), which allows a user to save common queries called "Code Snippets". These snippets are stored in the registry: HKEY_CURRENT_USER\Software\Aginity\NetezzaWorkbench\QueryAnalyzer\CodeSnippets

The registry entries are structured as follows, where a "Text" field stores the actual query : XP_example

A portion of the .reg text looks like this:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Aginity\NetezzaWorkbench\QueryAnalyzer\CodeSnippets]

[HKEY_CURRENT_USER\Software\Aginity\NetezzaWorkbench\QueryAnalyzer\CodeSnippets\NZ]

[HKEY_CURRENT_USER\Software\Aginity\NetezzaWorkbench\QueryAnalyzer\CodeSnippets\NZ\1] "Trigger"="sf" "Text"="select *

from

limit 1000;

" "CaretPosition"=dword:00000010

[HKEY_CURRENT_USER\Software\Aginity\NetezzaWorkbench\QueryAnalyzer\CodeSnippets\NZ\10] "Trigger"="rollnode" "Text"="SELECT mom.varReportId, mom.nodeId, mom.rollupTypeId, roll.riskFactorGroup, roll.effectType, mom.VAR, mom.mean FROM Moments mom, RollupTypeMapping roll WHERE mom.businessDate = (select businessDate from SysConfig) AND roll.businessDate = mom.businessDate AND mom.nodeId = 260591 AND mom.varReportId = 'DGV_BT_1D_CAD' AND roll.rollupTypeId = mom.rollupTypeId ORDER BY mom.nodeId, roll.rollupTypeId" "CaretPosition"=dword:0000018c

... and from Notepad++, showing linebreak details: registry_linebreaks

I attempted to migrate the snippets by:

  1. in regedit.exe on XP >> export "Code Snippets" branch
  2. in regexit.exe on W7 >> import the .reg file I save in #1

Windows pops up a message saying the registry was updated successfully, and in fact I can see new entries show up in the registry. However, almost all of the new entries are missing the critical "Text" field. For example, here is the important record "10" from above: W7_example

Can anyone help explain how to resolve this?

I noticed exactly one record that seemed to contain the Text field, and was populated correctly in W7. I have no idea what is different about this one, or why Windows would treat it differently. But it does show me a working example, and that the import should be possible.

Windows XP XP_text

Windows 7 W7_text

2
  • 2
    Please edit your question and include the raw text of the .REG file you're trying to import. Commented Jun 23, 2015 at 18:47
  • @Ƭᴇcʜιᴇ007 thanks for the feedback - I added an extract
    – Roberto
    Commented Jun 23, 2015 at 18:54

2 Answers 2

2

It's the carriage returns/new lines. The Registry importer doesn't like importing stuff with EOL/newlines/CR characters in it (even though you can export it successfully). You can check that theory by looking a the .reg file section that holds the TEXT file that DID import (the TO_CHAR example), I'd bet it has no carriage returns.

To get around it:

  • Export the registry key you want (ie: "HKEY_CURRENT_USER\MyTest"): reg export HKEY_CURRENT_USER\MyTest Test.reg
  • Then Save the key in binary format: reg save HKEY_CURRENT_USER\MyTest Test.bin
  • Then Import the .Reg file (on the new computer). reg import Test.reg
  • Then Restore the binary version overtop: reg restore HKEY_CURRENT_USER\MyTest Test.bin

You have to do both because "restore" doesn't recreate keys, so you use the exported/imported .Reg files to do that part, then Restore the binary data (including new line characters, etc.) into those now-existing keys.

Warning: I haven't fully tested this, as I don't have XP available to me.

2
  • thanks - I am looking at this more closely. I added a screenshot showing the linebreaks.
    – Roberto
    Commented Jun 23, 2015 at 20:13
  • this did it. I am not sure about the reg commands you mentioned. I just used regedit.exe on XP to export twice (in ".reg" and again "." hive). And then used regedit.exe on W7 to import twice (first the ".reg" and then the "." hive).
    – Roberto
    Commented Jun 23, 2015 at 20:36
2

The problem is the linebreaks. If you fix these, it will import successfully.

Firstly, you have missing linebreaks:

[HKEY_CURRENT_USER\Software\Aginity\NetezzaWorkbench\QueryAnalyzer\CodeSnippets\NZ\1] "Trigger"="sf" "Text"="select *

This should be:

[HKEY_CURRENT_USER\Software\Aginity\NetezzaWorkbench\QueryAnalyzer\CodeSnippets\NZ\1] 
"Trigger"="sf" 
"Text"="select *    ...

Secondly you have extra linebreaks:

"Text"="select *

from

limit 1000;

"

You may desire that as a snippet, but according to this old article on MSDN, a blank line identifies the start of a new registry path. It may be that Aginity had some scheme for encoding linebreaks in these registry keys which has been lost in the export process; regardless, if you remove the blank lines, it will import successfully.

Here's the "fixed" version of the .reg file you posted:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Aginity\NetezzaWorkbench\QueryAnalyzer\CodeSnippets]

[HKEY_CURRENT_USER\Software\Aginity\NetezzaWorkbench\QueryAnalyzer\CodeSnippets\NZ]

[HKEY_CURRENT_USER\Software\Aginity\NetezzaWorkbench\QueryAnalyzer\CodeSnippets\NZ\1] 
"Trigger"="sf" 
"Text"="select * from limit 1000;" 
"CaretPosition"=dword:00000010

[HKEY_CURRENT_USER\Software\Aginity\NetezzaWorkbench\QueryAnalyzer\CodeSnippets\NZ\10] 
"Trigger"="rollnode" 
"Text"="SELECT mom.varReportId, mom.nodeId, mom.rollupTypeId, roll.riskFactorGroup, roll.effectType, mom.VAR, mom.mean FROM Moments mom, RollupTypeMapping roll WHERE mom.businessDate = (select businessDate from SysConfig) AND roll.businessDate = mom.businessDate AND mom.nodeId = 260591 AND mom.varReportId = 'DGV_BT_1D_CAD' AND roll.rollupTypeId = mom.rollupTypeId ORDER BY mom.nodeId, roll.rollupTypeId" 
"CaretPosition"=dword:0000018c
4
  • thanks, I will try this. I assumed that since I used the Windows regedit.exe export command, there could not be any issues with formatting etc. I do not think that one entry that imported successfully had line breaks, which is probably why it worked.
    – Roberto
    Commented Jun 23, 2015 at 19:55
  • just to clarify, should it be CRLF for linebreaks? I added a screenshot in the original post showing that the file appears to have a number of breaks that did not show up when I pasted to superuser.
    – Roberto
    Commented Jun 23, 2015 at 20:11
  • @Roberto Yes, version 5 files have Unicode encoding and CRLF line endings. You can verify this by looking at an export.
    – Reg Edit
    Commented Jun 23, 2015 at 20:33
  • thanks again. A limitation of this approach is that I obviously lost all of the line breaks that were desirable in order to organize the queries. The binary approach alternately proposed seemed to avoid this.
    – Roberto
    Commented Jun 23, 2015 at 20:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .