[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Mayayana

8/6/2011 5:41:00 PM

I just ran across an odd quirk yesterday and
wondered if anyone knows about it:

Over the years, I occasionally get a command
line in a VB EXE that is surrounded by quotes. It
happens so seldom that I'm not in the habit of
checking for it, but it happened yesterday on XP.
Does anyone know about that?


17 Answers

(nobody)

8/6/2011 6:17:00 PM

0

"Mayayana" <mayayana@invalid.nospam> wrote in message
news:j1ju8u$iig$1@dont-email.me...
> I just ran across an odd quirk yesterday and
> wondered if anyone knows about it:
>
> Over the years, I occasionally get a command
> line in a VB EXE that is surrounded by quotes. It
> happens so seldom that I'm not in the habit of
> checking for it, but it happened yesterday on XP.
> Does anyone know about that?

Not enough info. Perhaps you dropped a file over the EXE or shortcut, or the
EXE was associated with an extension.


Mayayana

8/6/2011 9:30:00 PM

0

| >
| > Over the years, I occasionally get a command
| > line in a VB EXE that is surrounded by quotes. It
| > happens so seldom that I'm not in the habit of
| > checking for it, but it happened yesterday on XP.
| > Does anyone know about that?
|
| Not enough info. Perhaps you dropped a file over the EXE or shortcut, or
the
| EXE was associated with an extension.
|

The command line isn't a mystery. It could be either
method you mentioned. I just don't get why it sometimes
comes through with quotes. Maybe it just depends on
whether there are spaces in the command line? I've just
rarely run into it before.


GS

8/6/2011 11:46:00 PM

0

Mayayana explained :
>>>
>>> Over the years, I occasionally get a command
>>> line in a VB EXE that is surrounded by quotes. It
>>> happens so seldom that I'm not in the habit of
>>> checking for it, but it happened yesterday on XP.
>>> Does anyone know about that?
>>
>> Not enough info. Perhaps you dropped a file over the EXE or shortcut, or
>> the EXE was associated with an extension.
>>
>
> The command line isn't a mystery. It could be either
> method you mentioned. I just don't get why it sometimes
> comes through with quotes. Maybe it just depends on
> whether there are spaces in the command line? I've just
> rarely run into it before.

2cents worth:
I seem to recall anything with spaces needing to be wrapped in quotes.

--
Garry

Free usenet access at http://www.eternal-sep...
ClassicVB Users Regroup! comp.lang.basic.visual.misc


Thorsten Albers

8/7/2011 11:54:00 AM

0

Mayayana <mayayana@invalid.nospam> schrieb im Beitrag
<j1kblp$b69$1@dont-email.me>...
> The command line isn't a mystery. It could be either
> method you mentioned. I just don't get why it sometimes
> comes through with quotes. Maybe it just depends on
> whether there are spaces in the command line? I've just
> rarely run into it before.

Since the space character acts as the separator between commands in the
command line it doesn't make much sense to enclose the whole command line
in quote characters. Only enclosing one or more parts ('commands') of the
command line in quote characters makes sense since the quote characters
mean that any enclosed space character shall _not_ be treated as as the
command separator but simply as a space character.

--
Thorsten Albers

gudea at gmx.de

Mayayana

8/7/2011 12:33:00 PM

0

| Since the space character acts as the separator between commands in the
| command line it doesn't make much sense to enclose the whole command line
| in quote characters. Only enclosing one or more parts ('commands') of the
| command line in quote characters makes sense since the quote characters
| mean that any enclosed space character shall _not_ be treated as as the
| command separator but simply as a space character.
|

Yes, but in this case the whole command line is just a
file path. As Garry said, a path is typically wrapped if there
are spaces, but it doesn't seem to make sense for VB to
send a path through with quotes around it.

I've run into this problem so seldom that I wondered
if there were other facotrs involved, other than whether
a path has spaces. Perhaps memory is tricking me, but I
don't remember this being an issue on Win9x.


ralph

8/7/2011 4:53:00 PM

0

On Sun, 7 Aug 2011 08:32:32 -0400, "Mayayana"
<mayayana@invalid.nospam> wrote:

>| Since the space character acts as the separator between commands in the
>| command line it doesn't make much sense to enclose the whole command line
>| in quote characters. Only enclosing one or more parts ('commands') of the
>| command line in quote characters makes sense since the quote characters
>| mean that any enclosed space character shall _not_ be treated as as the
>| command separator but simply as a space character.
>|
>
> Yes, but in this case the whole command line is just a
>file path. As Garry said, a path is typically wrapped if there
>are spaces, but it doesn't seem to make sense for VB to
>send a path through with quotes around it.
>

I doubt "VB" has much to do with it. The VB CommandLine$ pretty much
just passes on what it is given. [*note below]

> I've run into this problem so seldom that I wondered
>if there were other facotrs involved, other than whether
>a path has spaces. Perhaps memory is tricking me, but I
>don't remember this being an issue on Win9x.
>

As Nobody noted: There is not enough information to provide an answer
as it depends on the 'tool' that generated the command line, and, if
any, any intermediate 'tool' that retrieves that command line for the
client.

Spaces as a delimiter is only of interest to a parser. As a practical
factor we only surround some arguments with double quotes so as to not
confuse a parser.

Note there can be two parsers involved that we don't want to confuse
in the process of presenting a command line to a Windows program. The
first one is the Command Line parser itself (as determined by
COMSPEC). We would have problems if we attempted to pass "&&" or "<<"
as arguments, for example. The second one is the C runtime library
which takes the parsed command line and packs it into a character
array (the argv block).

*I not exactly sure how VB6 'constructs' its command line. Back in the
day it appeared VB took the C library main argument argv memory block
and simply replaced the nuls with spaces. It always seemed strange to
me that they didn't simply provide a String array - after all they had
all the information. Thus it is more likely the VB developers took the
quick way out and used the MS specific preprocessor directive "__ARGV"
to grab the command line, and the 'code' I saw 'stripping away' nuls
came from that directive. In any case it doesn't matter, since when
the smoke clears VB gets a straight single string. <g>

When you start investigating "command lines" it is useful to
appreciate that there are two separate things going on here (just as
there is with any computing paradigm) -
The first one is the protocol, or how it ought to work;
the second is the implementation, or how it does work.

M$ uses a modified "DEC" protocol and part of that protocol says
'strings' will be surrounded by double quotes.

It also had the specification that single quotes would delimit
"literal values", but you'd have to go back 20+ years to see any
mention of it, and AFAIK nothing in the Windows world ever implemented
it outside of a few data-centric tools.

So theoretically a typical command line should look like this ...

ProgramA "filepath"

But the default, or actually better put since everything ends up as a
'string' anyway, the following is perfectly acceptable to most
clients.

ProgramA filepath

Some parsers (the implementers) would strip the double quotes, others
would not. This used to be a bit of a PITA in the old days, especially
when working with mixed platforms - UNIX, Windows, and different
compilers. You had to go the extra step of always checking for double
quotes and trimming them. So yes, I've seen this in the past. But now
days it is quite rare since we tend to work with a single platform and
compiler. For shrink wrap applications I still usually check 'n strip
- out of pure habit and old age. I hate telephone calls. <bg>

Also for completeness the protocol provides for the "/" to serve as an
option flag, but there is no implementation enforcement of such
critters in Windows.

All clients are pretty much on their own when it comes to command line
'reading'. The UNIX world is lucky as AT&T provided the getopts
utility. It served as a de facto standard command line protocol
implementer and enforcer. Windows never got one. More's the pity - a
ton of aggravation could have been avoided. <g>

Track down the specific actors involved in the transaction of interest
and you'll have your solution. Particularly note if COMSPEC is
involved, ie, whether you are using the DOS parser or not.

hth
-ralph

GS

8/7/2011 5:21:00 PM

0

2cents more...
I seem to recall running into what Ralph is talking about quite some
time ago with a 3rd party app the command line was being passed to. In
this case it only worked if the entire expression was wrapped in
quotes.

Since then, I've always wrapped with quotes to avoid this issue
repeating. The apparent behavior I've noticed is that the quotes
themselves don't pose any problems if they're NOT needed by the process
handling the action. I could be wrong but maybe Ralph can shed some
light on this!

--
Garry

Free usenet access at http://www.eternal-sep...
ClassicVB Users Regroup! comp.lang.basic.visual.misc


Thorsten Albers

8/7/2011 8:13:00 PM

0

Mayayana <mayayana@invalid.nospam> schrieb im Beitrag
<j1m0i8$1ud$1@dont-email.me>...
> Yes, but in this case the whole command line is just a
> file path. As Garry said, a path is typically wrapped if there
> are spaces, but it doesn't seem to make sense for VB to
> send a path through with quotes around it.

The command line is not build by VB, VB/the VB app just provides the
command line it has received in Command$(). Either your VB app has been
started by another app with the command line in question, or the VB app has
been started because it is the app associated with files of certain
filename extensions, and the command line has been passed according to the
file association setting in the registry (check the entry
\shell\open\command in HKCR\...).

--
Thorsten Albers

gudea at gmx.de

mm

8/7/2011 8:59:00 PM

0

El 07/08/2011 09:32 a.m., Mayayana escribió:

> Yes, but in this case the whole command line is just a
> file path.

OK, but I believe that when file paths have spaces they are put between
quote characters by Windows. Windows doen't check if it's the only
argument and you don't want the quotes.
Just check if the path is quoted and unquote it.

Mayayana

8/8/2011 3:01:00 AM

0

| The command line is not build by VB, VB/the VB app just provides the
| command line it has received in Command$(). Either your VB app has been
| started by another app with the command line in question, or the VB app
has
| been started because it is the app associated with files of certain
| filename extensions, and the command line has been passed according to the
| file association setting in the registry (check the entry
| \shell\open\command in HKCR\...).
|

In the current case it was started by a dropped file.
You make an interesting point, though. Command lines
in the Registry vary. Some have %1 while others have
"%1".