The first example didn't work so i used the last one but since i need to have everything in one code line i used this code below this one should work but it doesn't.
CMD /Q /C V:ON SET "FM=FolderName" & ECHO "!FM!"
Something to learn from this example.
The command string should follow /C or /K. Not using /C or /K immediately before the command string can expect failure.
V:ON would be an invalid parameter as a leading forward slash would be expected. CMD seems to ignore V:ON and thus delayed expansion is not turned on.
The command string has more then 2 double quotes. CMD may strip outer double quotes which may leave the command string as invalid. I would add extra outer double quotes on the command string and use the /S parameter to force CMD to strip those outer double quotes to be safe.
This information can be viewed by using the command CMD /? .
Following the information I mentioned above, I would use
CMD /S /Q /V:ON /C "SET "FM=FolderName" & ECHO "!FM!""
which tests as working.
Edited by MHz, 13 March 2015 - 09:20 PM.