Any good?
@echo off
for /f "delims=" %%a in ('type command.file') do set variable="%%a"
echo %variable%
You can safely assign
set MyVar=%1
or (in the case of FOR)
set MyVar=%%A
but
set MyVar2=%MyVar%
will generate an error (since command interpreter first
evaluates %MyVar% to "real string", so that you get
set MyVar2=Boogie & Woogie
and then "'Woogie' is not recognized as an internal or
external command, operable program or batch file.").
But things are different in EnableDelayedExpansion mode.
The command
set MyVar2=!MyVar!
will succeed in spite of MyVar' contents. The only
fatal (?) thing will be exclamation mark in assignments
like "set MyVar=%1" or "set MyVar=%%A".