I mentioned Reg2Nsis in Chapter I when I introduced NSIS. It can convert .reg files to NSIS scripts, so it will convert the code
REGEDIT4
[HKEY_CURRENT_USERSoftwareMySoftware]
“ArchiveSupport”=”C:Program FilesDatadir”
“LanguageFile”=”English.lng”
“RootDir”=”J:”
[HKEY_CURRENT_USERSoftwareNotMySoftware]
“Rev”=”3″
“Visible”=”0″
“DockedTo”=”ListViewDock”
“LastDock”=”ListViewDock”
to
WriteRegStr HKEY_CURRENT_USER “SoftwareMySoftware” “ArchiveSupport” “$PROGRAMFILESDatadir”
WriteRegStr HKEY_CURRENT_USER “SoftwareMySoftware” “LanguageFile” “English.lng”
WriteRegStr HKEY_CURRENT_USER “SoftwareMySoftware” “RootDir” “J:”
WriteRegStr HKEY_CURRENT_USER “SoftwareNotMySoftware” “Rev” “3″
WriteRegStr HKEY_CURRENT_USER “SoftwareNotMySoftware” “Visible” “0″
WriteRegStr HKEY_CURRENT_USER “SoftwareNotMySoftware” “DockedTo” “ListViewDock”
WriteRegStr HKEY_CURRENT_USER “SoftwareNotMySoftware” “LastDock” “ListViewDock”
As you can see, the first is a normal .reg file, and the resulting code is an NSIS code. This means that you can put this code in your script and it will be equal as if you imported a registry file. So if you want, you can get rid of RegInfo.reg if you build its contents into the launcher.
How to use Reg2Nsis?
Go to “ToolsReg2NSIS” and execute “InstallContextMenu.exe”. This will put a line into the context menu of .reg files. So if you right-click on a .reg file (i.e. on RegInfo.reg), you’ll find an entry saying “Convert to NSIS script”. If you select this, it will create a RegInfo.nsh file in the same directory. Open this .nsh file with a text editor. The first eight lines (which are commented out) is about the auther of Reg2NSIS and such things. After them come the lines we want, and the last line of the .nsh file (commented out) tells us that it is the end of the file.
When does Reg2Nsis come handy?
If you wish, you may convert RegInfo.reg to RegInfo.nsh, and then copy its contents to your .nsi script. Although this method is absolutely correct, I use it only occasionally. You’re asking why? Because you may want to update your software (in the “Appdata” directory”) and if it is serial-protected, the serial for the new version may not be the same as it was in the earlier version. In these cases you should only update RegInfo.reg and your portable will still working. Otherwise, if you have no RegInfo.reg, you have to modify the script, which is a bit more difficult.
As for Settings.reg you shouldn’t use Reg2NSIS to convert it to NSIS code, because Settings.reg changes when you set an option in the main program, or if it contains paths. So hard-coding it to the launcher makes no sense.
RegClean.reg can be converted to NSIS code because it is fairly constant. However, the path or paths in RegClean.reg may change if you update the main program, so take care of it when updating.
But when Reg2NSIS come really handy is when you have to put absolute paths to the registry. As I mentioned that earlier, you can use “$EXEDIR” (which is the launcher’s current location) to put the current path of the launcher into the registry, no matter in what drive it is located and in which directory/subdirectory. So, for example, modifying the Reg2NSIS-generated code from
WriteRegStr HKEY_CURRENT_USER “SoftwareMySoftware” “ArchiveSupport” “$PROGRAMFILESDatadir”
WriteRegStr HKEY_CURRENT_USER “SoftwareMySoftware” “LanguageFile” “English.lng”
WriteRegStr HKEY_CURRENT_USER “SoftwareMySoftware” “RootDir” “J:”
to
WriteRegStr HKEY_CURRENT_USER “SoftwareMySoftware” “ArchiveSupport” “$EXEDIRAppdataDatadir”
WriteRegStr HKEY_CURRENT_USER “SoftwareMySoftware” “LanguageFile” “English.lng”
WriteRegStr HKEY_CURRENT_USER “SoftwareMySoftware” “RootDir” “$EXEDIR”
will change paths in “ArchiveSupport” and “Rootdir” entries dynamically, according to the launcher’s current location.
If a program requires its paths to be absolute ones in the registry then this is the only way to do this. Of course, you can do this without Reg2NSIS but I think it is much more convenient then writing all the code by hand. You may face a problem when you have to convert hundreds of paths, now imagine how much easier is to do it with Reg2NSIS…
However, if your .reg file contains hex values, then NSIS cannot import it to the registry (at least the current version). So, as a general rule, if your .reg file contains hex values, use the registry plugin’s restorekey method to put it in the registry:
${registry::RestoreKey} “$EXEDIRportableRegInfo.reg” $R0
Otherwise you can use the code converted with Reg2Nsis.
You should always check if the generated code is right. In some cases you have to modify it manually but Reg2Nsis works well in general.

[...] 2.Reg2Nsis [...]