Computing.Net > Forums > Programming > Ampersand in batch file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Ampersand in batch file

Reply to Message Icon

Name: benton
Date: June 27, 2005 at 00:08:56 Pacific
OS: win2000
CPU/Ram: P4 CPU 3.00GHz / 1024
Comment:

I am writing a batch file to create some secondary files but the ampersand (&) symbol is giving me some problems in the following line,

echo MbeSetAppVariable "", "msToolSettings.placeText.type", 1& >>txt_ROAD_ORIGIN.bas

is there any way to get the above line to work and also keep the ampersand (&) symbol in the results.

The following line works fine because the ampersand (&)has been removed from the line.

echo MbeSetAppVariable "", "msToolSettings.placeText.type", 1 >>txt_ROAD_ORIGIN.bas

Thank you in advance for any assistance with this problem.


Thank you in advance for any assistance with this problem.

Ben



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: June 27, 2005 at 00:58:53 Pacific
Reply:

Hi Benton,

Yeah, problem is that & has special meaning in NT CMD.

This "works" but you get the double quotes in the BAS:

C:\temp\-\amp>echo "MbeSetAppVariable "", "msToolSettings.placeText.type", 1 &"
>>txt_ROAD_ORIGIN.bas

I wondered if this could be gotten around by starting a COMMAND shell where, I'd think, & has no special meaning. Still got the error.

M2


If at first you don't succeed, you're about average.


0

Response Number 2
Name: Mechanix2Go
Date: June 27, 2005 at 02:07:54 Pacific
Reply:

I think this will need to be worked around.

You could use:

Change

And in your echo line use a string like ###, then:

change txt_ROAD_ORIGIN.bas "###" "&"

M2


If at first you don't succeed, you're about average.


0

Response Number 3
Name: benton
Date: June 27, 2005 at 19:56:44 Pacific
Reply:

I tried your suggestion by creating a line like this;

echo MbeSetAppVariable "", "msToolSettings.placeText.type", 0### >>txt_ROAD_ORIGIN.bas

and then created another batch file with the following in it;

change txt_ROAD_ORIGIN.bas "###" "&"

I placed the change.com file in the same folder.

It didnt produce any results is there something that I have done wrong.

Thank You


Ben


0

Response Number 4
Name: Mechanix2Go
Date: June 27, 2005 at 21:55:35 Pacific
Reply:

Usually when CHANGE runs [actually always] it will give a result of either "changed" or "not changed".

"It didnt produce any results"

Well, either it did the change or it did not.

You can test this with a trivial testfile:

::====================
@echo off
echo one > testfile
change testfile "one" "two"
echo.
type testfile
::=====================


M2


If at first you don't succeed, you're about average.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Ampersand in batch file

Date Routines in Batch Files www.computing.net/answers/programming/date-routines-in-batch-files/15590.html

%DATE% in batch files with win98 www.computing.net/answers/programming/date-in-batch-files-with-win98/4007.html

Progress bar in batch file www.computing.net/answers/programming/progress-bar-in-batch-file/14919.html