Archive: Having problems with trailing backslash


Having problems with trailing backslash
I've created my first NSIS script (makes you cringe when you see that in a post, I'm sure) and I used the EclipseNSIS plug-in for Eclipse. I'm installing a file, adding a registry key, and adding string values to the registry key. Someone else has inherited the development of the program I'm installing and I'm trying to help him deploy it. I've spent hours searching the forums, looking in the docs/faqs, and searching Google. I haven't found anything to get this to work or maybe I'm just too tired right now. :igor:

One of the string values added to the registry is

BASE_DIR=\\server\share\folder$\
The EclipseNSIS created this line of code to add it to the registry:
WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\company\program BASE_DIR \\server\share\folder$\


Compiling gives me this error:
WriteRegStr expects 4 parameters, got 8.
Usage: WriteRegStr rootkey subkey entry_name new_value_string
root_key=(HKCR|HKLM|HKCU|HKU|HKCC|HKDD|HKPD|SHCTX)
Error in script "C:\Documents and Settings\me\My Documents\setup_silent.nsi" on line 74 -- aborting creation process
Line 75 is
WriteRegStr HKLM "${REGKEY}\Components" Main 1

which is how it gets 8 parameters in the error.

I do not have control over the $ and the trailing backslash.

I have tried many different variations of $$, \\, and all three types of quotes. I've managed to just get warnings, but the output is never right in the registry. I end up with multiple "$"s, multiple "\"s, no "$", and/or no trailing "\" at the end of the string value in the registry.

Removing the trailing backslash allows the script to compile and run just fine (except now I do not have the trailing backslash).

Can someone figure this out? If not, perhaps I'll look at getting NSIS to run an embedded cmd script that loads an embedded .reg file. I was just (futilely) trying to keep it all NSIS. Maybe the answer is to add the string without the trailing backslash and then concatenate the trailing backslash. Perhaps I'll see how to do that tomorrow.

Thank you in advance for any help/suggestions.

Use quotes around the path.

Stu


Afrow, I had tried that with ", ', and ` quotes around that parameter.

Using ":

WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\company\program BASE_DIR "\\server\share\folder$\"

I get this error:
Error: unterminated string parsing line at C:\Documents and Settings\me\My Documents\setup_silent.nsi:73
Error in script "C:\Documents and Settings\me\My Documents\setup_silent.nsi" on line 73 -- aborting creation process
Using ':
WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\company\program BASE_DIR '\\server\share\folder$\'

I get this error:
Error: unterminated string parsing line at C:\Documents and Settings\me\My Documents\setup_silent.nsi:73
Error in script "C:\Documents and Settings\me\My Documents\setup_silent.nsi" on line 73 -- aborting creation process
Using `:
WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\company\program BASE_DIR `\\server\share\folder$\`

I get this error:
Error: unterminated string parsing line at C:\Documents and Settings\me\My Documents\setup_silent.nsi:73
Error in script "C:\Documents and Settings\me\My Documents\setup_silent.nsi" on line 73 -- aborting creation process
I was just thinking about $\ being used to escape quotes, which is why just putting quotes around that parameter does not work. So, I just tried this:
WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\company\program BASE_DIR $\"\\server\share\folder$\$\"

Now it will compile and run, but the string in the registry has double quotes around it (i.e.,
"\\server\share\folder$\"
and I want
\\server\share\folder$\
.

Any other ideas? Should I just pull out the quotes after writing the string? Can you do that? Like I said before, I’ve tried all different kinds of combinations with the dollar sign, the backslash, and the 3 different quotes, like …$$\, …$$\\, “…$$\\”, etc., but I’m not the pro like most of you out there providing help. I was hoping someone more familiar with the syntax or NSIS scripting could tell the correct way to write this line or how to get around this issues.

Thank you and I apologize for the long posts. I just want to make sure I'm being thorough.

"\\server\share\folder\"

Stu