In some snippets of code, I see the set command in use, but this time there are a couple of modifications to it. An example is... observe the code snipped below please...
set "variable=happy"
What's up with the apostrophes? What unique function does it give off? Help? Thanks.
Set Problem
Moderator: DosItHelp
Re: Set Problem
Edited:
I removed the answer because it wasn't right, sorry
I removed the answer because it wasn't right, sorry

Last edited by abc0502 on 27 Sep 2012 06:22, edited 1 time in total.
Re: Set Problem
Not quite. SET will happily accept spaces
The surrounding double quotes protect the batch file from any poison characters than can exist in the variable, like & < > | etc
When placed in that position the double quotes themselves are not included in the variable.
This will work too but it adds the double quotes to the variable.
set abc="a 1 2 & 3 > 4 5 6 < zyx"
The surrounding double quotes protect the batch file from any poison characters than can exist in the variable, like & < > | etc
When placed in that position the double quotes themselves are not included in the variable.
This will work too but it adds the double quotes to the variable.
set abc="a 1 2 & 3 > 4 5 6 < zyx"
Re: Set Problem
And it has one additional effect.
It safes the assignment for unwanted trailing spaces.
Will only set the value to var, the value begins after the equal sign and ends just before at the last quote in the line.
So even this will work
jeb
It safes the assignment for unwanted trailing spaces.
Code: Select all
set "var=value" <SPACE>
So even this will work
Code: Select all
set "var=value" this will not be assigned
jeb