cmd.exe documentation

  • Thread starter Thread starter Larry
  • Start date Start date
L

Larry

Is there any online documentation for cmd.exe? In particular I am
interested in all the rules for special characters. For example, is
there a way to get pass a double-quote as a command-line argument?
 
Larry said:
Is there any online documentation for cmd.exe? In particular I am
interested in all the rules for special characters. For example, is
there a way to get pass a double-quote as a command-line argument?

Command-line reference [includes links to New ways to do familiar
command-line tasks, New command-line tools, Command-line reference A-Z,
Command shell overview and Configure the command prompt].

http://tinyurl.com/5bkwj
 
Larry said:
Is there any online documentation for cmd.exe? In particular I am
interested in all the rules for special characters. For example, is
there a way to get pass a double-quote as a command-line argument?

Start>Help & Support
look for "command-line reference A-Z"

Try asking in alt.msdos.batch.nt if you can't find the answer there.

commandname/? at the prompt gives you on-line documentation.

No idea what you mean by "get pass a double-quote as a command-line
argument"

batchfilename "an argument"

will pass "an argument" (including the quotes) as %1 ti the batch file
BATCHFILENAME.BAT
to strip the quotes, use %~1

HTH

....Bill
 
billious said:
No idea what you mean by "get pass a double-quote as a command-line
argument"

What I mean is... suppose I want to pass a command-line argument to a
program, and that arguement may include a double-quote. For example,
I want to pass the sentence:

Hi there "dude"!

as an argument to a command. If it didn't include double-quotes, I
could just enclose the whole think in double-quotes, but I can't do:

myCommand "Hi there "dude"!"

because that would be nesting the double quotes. So how *would* I pass
in an argument like that?
 
Look under various commands.

What is wrong if you don't do anything special. The escape char is ^ but " is the same as ^" in most circumstances you are talking about.
 
Larry said:
What I mean is... suppose I want to pass a command-line argument to a
program, and that arguement may include a double-quote. For example,
I want to pass the sentence:

Hi there "dude"!

as an argument to a command. If it didn't include double-quotes, I
could just enclose the whole think in double-quotes, but I can't do:

myCommand "Hi there "dude"!"

because that would be nesting the double quotes. So how *would* I pass
in an argument like that?

Why can't you "do"

myCommand "Hi there "dude"!"

It works perfectly well for me.

The parser appears to do this: (with quotes)
If the first character of a token is a double-quote, then the token consists
of all characters from that opening-quote up to the next double-quote that
is either at end-of-line or is followed by a separator (space or comma - I
haven't tested any others) - including the quotes.

%~n (where n is a parameter token-number, 1 to 9) will remove the enclosing
quotes ONLY.

Depending on how you are processing a token, certain characters may need to
be escaped with a prefixed caret (^)

HTH

....Bill
 
Why can't you "do"
myCommand "Hi there "dude"!"

It works perfectly well for me.

The parser appears to do this: (with quotes)
If the first character of a token is a double-quote, then the token consists
of all characters from that opening-quote up to the next double-quote that
is either at end-of-line or is followed by a separator (space or comma - I
haven't tested any others) - including the quotes.

%~n (where n is a parameter token-number, 1 to 9) will remove the enclosing
quotes ONLY.

Depending on how you are processing a token, certain characters may need to
be escaped with a prefixed caret (^)

HTH

In my tests, if you do:
myCmd "hi "there" dude"

the parameter comes in as:

hi there dude

I would want it to be:

hi "there" dude

I tried escpaing the quotes with a caret (^):
myProg "hi ^"there^" dude"

and I got:

hi ^there dude

It almost looks like the caret actually does nothing special at all,
but then the second one is inexplicity lost.

What I'm really looking for is a way to take an arbitrary string (which
may have double-quotes, carets or other puntuation) and somehow pass it
into a program as a single parameter. By way of comparison, in most
Unix shells you could enclose the whole string in single quotes ('),
after replacing any internal single quotes by the sequence: '\''
 
Larry said:
In my tests, if you do:


the parameter comes in as:

hi there dude


Try this: myCmd "hi ""there"" dude"

I may be all mixed up and remembering something from my mainframe days, but
I remember this being the way to do it someplace.
 
Larry said:
In my tests, if you do:


the parameter comes in as:

hi there dude

I would want it to be:

hi "there" dude

I tried escpaing the quotes with a caret (^):


and I got:

hi ^there dude

It almost looks like the caret actually does nothing special at all,
but then the second one is inexplicity lost.

What I'm really looking for is a way to take an arbitrary string (which
may have double-quotes, carets or other puntuation) and somehow pass it
into a program as a single parameter. By way of comparison, in most
Unix shells you could enclose the whole string in single quotes ('),
after replacing any internal single quotes by the sequence: '\''

Using this highly-complex file:

@echo off
echo arg-1:%1(%~1)
echo arg-2:%1(%~2)

the response to
thatbat "hi "there" dude"

is
arg-1:"hi "there" dude"(hi "there" dude)
arg-2:()

Regrettably, Microsoft systems don't seem to follow common sense, and it's
more important that it gets done quick and cheap rather than doing the job.
Dealing with all posible user-input is next to impossible - even if you can
get your environment variables to accept the appropriate values, the parser
will interpret the special characters inconveniently.

Microsoft wants to get rid of DOS, and has recruited a flock of parrots who
will endlessly repeat "there is no DOS." Consequently, the emulation is made
deliberately hard to use and incompatible with the previous versions and
utilities are added, removed and implemented willy-nilly.

What you are intended to do is to pay Microsoft for a programming platform,
and continue shelling out for "upgrades" to overcome their changing
environment. You then write the program yourself, using "visual" methods,
maintaining it each OS release.

....Bill
 
Back
Top