ECHOing the _CWD with a & in the path

Apr 2, 2011
1,607
15
55
North Carolina, USA
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

  • EmailAddr.btm
    1.4 KB · Views: 140

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,689
106
Albuquerque, NM
prospero.unm.edu
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.
 
Jan 12, 2014
524
11
Switzerland, SO
Uhh, NONSENSE from me, SORRY!

Works for "direct" echo commands (messages) ...

Code:
[C:\]echo `test&test`
test&test

but not for functions or variables ...
 

Similar threads