Q:

Delayed expansion does not work in entire batch script

I am working on a script that will use Putty command line to login to several systems just by executing a batch file. The batch reads the list of server names I wish to launch from a text file without issue. 
The issue arises when using the password entered at a "set /p". The password has special characters in it, such as the ampersand. To use the variable, I am attempting to use DELAYEDEXPANSION.
I can echo the variable with the password fine using !pass! However, when used within a for loop where putty is called, the DELAYEDEXPANSION seems to fail. The result is literally !pass!.
SETLOCAL ENABLEDELAYEDEXPANSION
set /p  destination="Enter the file name: "
set /p "pass=Your LAN PASSword: "

ECHO Pass=!pass!

pause
for /F %%z in (%destination%) do (
start C:\DEV\Utilities\putty\putty -ssh %username%@%%z -pw !pass! -m "C:\DEV\Utilities\putty\commands" -t
timeout /t 01 /nobreak > NUL
) 
pause

If I use the variable with percent signs like %pass%, the password is not correct. For instance "c&ndyCone" ends up as "c  & ndyCone" (less the quotes).
Any suggestions to pass the correct password to Putty?

A:

Your problem here isn't about delayed expansion but the neither double quoted nor escaped char &.
So it is interpreted as command concatenation thus breaking your one command line into two - the second starting with the remainder of the password which is hardly a valid command: ndyCone 
Second is that start interprets the first argument in double quotes as the window title.
Try:
::commented out SETLOCAL ENABLEDELAYEDEXPANSION
set /p  destination="Enter the file name: "
set /p "pass=Your LAN PASSword: "

ECHO Pass="%pass%"

pause
for /F %%z in (%destination%) do (
start "" C:\DEV\Utilities\putty\putty -ssh %username%@%%z -pw "%pass%" -m "C:\DEV\Utilities\putty\commands" -t
timeout /t 01 /nobreak > NUL
) 
pause

