ECHOing the _CWD with a & in the path

#1
I have EmailAddr.btm which is attached and it's causing output for example:

Code:
In: C:\Program Files (x86)\Cyberlink\WaveEditor\web
====
In: C:\Program Files (x86)\DoubleKiller Pro
====
In: C:\Program Files (x86)\Eltima Software
====
In: C:\Program Files (x86)\Eltima Software\SWF

OnError.btm: Not a valid command. You may edit it or
press ENTER to abort it.

FLV Player

[C:\]dir /a: "C:\Program Files (x86)\Eltima Software\SWF*"

Volume in drive C is Win7_Galloway   Serial number is aea6:a855
Directory of  C:\Program Files (x86)\Eltima Software\SWF*

3/28/2013   1:35         <DIR>    SWF & FLV Player
                   0 bytes in 0 files and 1 dir
     308,934,520,832 bytes free

[C:\]dir /a: /f "C:\Program Files (x86)\Eltima Software\SWF*"
C:\Program Files (x86)\Eltima Software\SWF & FLV Player

[C:\]
This is being caused by :

setdos /x-5
echo In: %_CWD
setdos /x+5

Is there a simplier way to echo a string that might include the "&" char?
 

Attachments

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,555
46
Albuquerque, NM
prospero.unm.edu
#4
Here's another way:

Code:
setlocal
setdos /c0xfffe
echo %_cwd
endlocal
The argument to /C should be a character that will never appear in any filename. I picked 0xFFFE because, per the Unicode spec, it's officially Not Even A Character; other values would work.