da_bear
24th September 2006 16:42 UTC
Write reg string containing "\""
Hey
I am trying to set the value of a regsitry string to
something that in C would look like this
"\"ASDF\" \"%1\"". Can anyone help me?
Oh, I almost forgot ...
Which are the escape characters in the NSIS script language?
thanks
Mr Bear
Animaether
24th September 2006 17:27 UTC
From a Search in the Help File for "escape"
Result 1: "Script Files"
2.2 Script Files
If you want to use a double-quote in a string you can either use $\" to escape the quote or quote the string with a different type of quote such as ` or '.
Result 2: "Script File Format"
4.1 Script File Format
Quotes only have the property of containing a parameter if they begin the parameter. They can be either single quotes, double quotes, or the backward single quote.
You can escape quotes using $\:
MessageBox MB_OK "I'll be happy" ; this one puts a ' inside a string
MessageBox MB_OK 'And he said to me "Hi there!"' ; this one puts a " inside a string
MessageBox MB_OK `And he said to me "I'll be fucked!"` ; this one puts both ' and "s inside a string
MessageBox MB_OK "$\"A quote from a wise man$\" said the wise man" ; this one shows escaping of quotes
So...
WriteRegStr HKCU "Software\myApp\" "Somevar" "$\"ASDF$\" $\"%1$\""
or
WriteRegStr HKCU "Software\myApp\" "Somevar" '"ASDF" "%1"'
or
WriteRegStr HKCU "Software\myApp\" "Somevar" `"ASDF" "%1"`
You'll see the third variation used a lot in scripts as a backward quote is practically never used in plain writing or in parameters/arguments/etc. in command lines and other computer-related instances.