In a Windows XP .bat file, how do I set a variable value to use double quote? I couldn't find special characters for batch file.
SET myVariable= " \"myValue \" "
Use double percent signs ( %% ) to carry out the for command within a batch file. Variables are case sensitive, and they must be represented with an alphabetical value such as %a, %b, or %c. ( <set> ) Required. Specifies one or more files, directories, or text strings, or a range of values on which to run the command.
Double quotes enable escaping through the use of the backslash (\). For example, if the special character semicolon is a value that is double-quoted, it should be represented as backslash semicolon (\;) so that the Integration Engine knows that the actual value (;) should be used.
When referencing a variable, it is generally advisable to enclose its name in double quotes. This prevents reinterpretation of all special characters within the quoted string -- except $, ` (backquote), and \ (escape).
inside double-quoted strings, use `" or "" to escape double-quotes. inside single-quoted strings, use '' to escape single-quotes.
You can use the method @Patrick Cuff has offered or you can do it quite simply:
SET var="Value"
Let's see if it works...
ECHO %var%
and the output is:
"Value"
Yes! :)
If this is for Windows, you need to escape the double quotes with a caret (^
):
set myVariable=^"myVlaue^"
Putting single quotes around the value won't work, the value will include the single and double quotes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With