From: Joe Duchtel on
Hello -

I have an application for which I need to pass in a path as command
argument. Neither of the following two statements will not work as
the command argument is split at the space ...

Dim lCommandArgument() as String = Microsoft.VisualBasic.Command()
lComandArgument(0)

My.Application.CommandLineArgs(0)

So a "C:\Document and Settings" results in "C:\Document".

Is there any way to make this work? I cannot use the Sub Main(ByVal
aArguments() As String) as I use a Form.

Would anybody have a slick regular expression or anything else that
will parse for the double quotes and treat everything enclosed as a
single argument?

Thanks!
Joe
From: Family Tree Mike on
On 1/26/2010 5:05 PM, Joe Duchtel wrote:
> Hello -
>
> I have an application for which I need to pass in a path as command
> argument. Neither of the following two statements will not work as
> the command argument is split at the space ...
>
> Dim lCommandArgument() as String = Microsoft.VisualBasic.Command()
> lComandArgument(0)
>
> My.Application.CommandLineArgs(0)
>
> So a "C:\Document and Settings" results in "C:\Document".
>
> Is there any way to make this work? I cannot use the Sub Main(ByVal
> aArguments() As String) as I use a Form.
>
> Would anybody have a slick regular expression or anything else that
> will parse for the double quotes and treat everything enclosed as a
> single argument?
>
> Thanks!
> Joe

It sounds like the problem is how you created the call to the
executable, not the way you are reading the arguments in the code. To
pass something in with spaces, surround it with quotes. To include a
double quote as part of a string, put double quotes twice.

So, this call:

someprog.exe "c:\program files\myapp" "A string with a "" double quote"

would have two arguments, the second having both spaces and double
quotes internally.

--
Mike
From: Joe Duchtel on
On Jan 26, 5:33 pm, Family Tree Mike <FamilyTreeM...(a)ThisOldHouse.com>
wrote:
> On 1/26/2010 5:05 PM, Joe Duchtel wrote:
>
>
>
>
>
> > Hello -
>
> > I have an application for which I need to pass in a path as command
> > argument.  Neither of the following two statements will not work as
> > the command argument is split at the space ...
>
> > Dim lCommandArgument() as String = Microsoft.VisualBasic.Command()
> > lComandArgument(0)
>
> > My.Application.CommandLineArgs(0)
>
> > So a "C:\Document and Settings" results in "C:\Document".
>
> > Is there any way to make this work?  I cannot use the Sub Main(ByVal
> > aArguments() As String) as I use a Form.
>
> > Would anybody have a slick regular expression or anything else that
> > will parse for the double quotes and treat everything enclosed as a
> > single argument?
>
> > Thanks!
> > Joe
>
> It sounds like the problem is how you created the call to the
> executable, not the way you are reading the arguments in the code.  To
> pass something in with spaces, surround it with quotes.  To include a
> double quote as part of a string, put double quotes twice.
>
> So, this call:
>
> someprog.exe "c:\program files\myapp" "A string with a "" double quote"
>
> would have two arguments, the second having both spaces and double
> quotes internally.
>
> --
> Mike- Hide quoted text -
>
> - Show quoted text -

Hello -

Thanks for the response! I did use double quotes but somewhere while
I was testing I screwed up and didn't try the
My.Application.CommandLineArgs(0) when I passed in the argument(s)
that way. It's working just fine now!

Thanks again,
Joe