Archive: overwrite regkeys


overwrite regkeys
hello,

i use "overwrite off" for my "file" commands.
can i also use it "writeregstr ..." ?
i dont want to overwrite regkeys. is it possible?


no, but you can try to read it first, and only write if it sets the error flag (or returns empty string)


Yes, that's right. The best way is write your own macro ;-)


I have a long list (50) of RegKeys like this:

WriteRegStr HKLM "Software\x\x" "abc" "def"
...
WriteRegStr HKLM "Software\x\x" "asd" "gfd"


I only want to write them if they not exist. Can you please give me the code for this problem??

Thnaks for your help
aemik


Yes, I can. Sorry for that Czech names ;)

I can also provide script which converts .reg file into NSIS commands like ${registry::________} ... ... ... ...


The script was too big.


thank you for help.

How can i include this script and how can i use it for my registry keys?


Copy / paste?

Try something like ${ZapisReg} "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion" "ProductId" "this is really CRAP!" "REG_SZ"


where is registry.nsh?


Just use a macro:

!macro _WriteReg Type Root Key Name Value
Push $R0
ClearErrors
ReadReg${Type} $R0 `${Root}` `${Key}` `${Name}`
Pop $R0
IfErrors 0 +2
WriteReg${Type} `${Root}` `${Key}` `${Name}` `${Value}`
!macroend

!define WriteRegDWORD `!insertmacro _WriteReg DWORD`
!define WriteRegBin `!insertmacro _WriteReg Bin`
!define WriteRegStr `!insertmacro _WriteReg Str`


${WriteRegDWORD} HKLM `Software\MyApp` `Blah1` 1
${WriteRegBin} HKLM `Software\MyApp` `Blah2` ABCD
${WriteRegStr} HKLM `Software\MyApp` `Blah3` Hello

Edit: shortened.

Stu

Nice. Why should I do it simply if I can do it intricately? :)