Archive: Adding Reg Keys From .reg File?


Adding Reg Keys From .reg File?
Is it possible to have NSIS download a .reg file from a server and then add the keys in it to the registry?


EDIT: See this Archive page Reg2Nsis - convert registry info into NSIS commands

But I never used it. And it's big (164 kb).


I dont know that register part but what I do know is
how to donwload a file :
;----------------------------------------------------------

EXAMPLE :
file = bla.exe
directory = $PROGRAMFILES
; the name and directory you want
StrCpy $2 "$PROGRAMFILES\bla.extension"
; the url (dont set " between the url)
NSISdl::download URL://....... $2
Pop $0
; if you want to open the file
ExecWait "$PROGRAMFILES\bla.exe"

;----------------------------------------------------------

NOTE : MUST BE IN A SECTION


You could also use the ExecShell command to import the registry file, however you will get an extra dialogs asking if you want to import the specified file and saying that the import was sucessfull. Unless there is an option to make regedit run in silent mode?

Vytautas


It's not a good idea to rely on external applications like regedit.


I know that is the case in general, but I do not see any harm in relying on regedit, it is available in all windows version.

Especially since, from my understanding of the original question, the info in the .reg file is not available at the compile time and thus cannot be converted into an NSIS script. Therefore you have two options. One is to rely on an external program, regedit, or two to get your NSIS script to manually phrase the downloaded .reg file and then run equivalent NSIS commands.

Personally I think that the first option would be more efficient and less error prone.

Vytautas


.reg files are like .ini files... so have a way to do that with functions. Am I right? (the difference is that .reg files have a starting word to indentify if it's a .reg file)


There is a Batch file command to import reg keys silently, but then you get the batch dialog.


Originally posted by deguix
EDIT: See this Archive page Reg2Nsis - convert registry info into NSIS commands

But I never used it. And it's big (164 kb).
That's neat! Thanks!

There is a Batch file command to import reg keys silently, but then you get the batch dialog.
But in this case have the nsExec plugin to just get the output.

Ok I have an idea:

Have nsDl download the reg file from the net into the Temp folder
Make a batch file with the lines regedit.exe /s C:\Windows\Temp\TheRegFile.reg which tells the batch not to show the Are you sure dialog.
Then we have nsExec execute the batch without the dialog and everything goes well.

Do you think that would work?