How to pass parameters to a windows application

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

How to pass parameters to a windows application

Jason Pyeron
I am at my wits end trying to figure out how to execute this in bash

C:\WINDOWS>cmd /c "start "" "C:\Documents and Settings\All
Users\Desktop\projects\crisfield\trunk\etc""

jpyeron@phoenix /projects/crisfield
$ cmd /c "\"start \"\" \"C:\\Documents and Settings\\All
Users\\Desktop\\projects\\crisfield\\trunk\\etc\"\""
The filename, directory name, or volume label syntax is incorrect.

jpyeron@phoenix /projects/crisfield
$ cmd /c '\"start \"\" \"C:\\Documents and Settings\\All
Users\\Desktop\\projects\\crisfield\\trunk\\etc\"\"'
The filename, directory name, or volume label syntax is incorrect.

jpyeron@phoenix /projects/crisfield
$ cmd /c '\"start \"\" \"C:\\Documents and Settings\\All
Users\\Desktop\\projects\\crisfield\\trunk\\etc\"\"'
The network path was not found.

jpyeron@phoenix /projects/crisfield
$ cmd /c "start \"\" \"C:\\Documents and Settings\\All
Users\\Desktop\\projects\\crisfield\\trunk\\etc\""
# A windows alert box pops up saying \\ The network path was not found.

--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-                                                               -
- Jason Pyeron                      PD Inc. http://www.pdinc.us -
- Principal Consultant              10 West 24th Street #100    -
- +1 (443) 269-1555 x333            Baltimore, Maryland 21218   -
-                                                               -
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
This message is copyright PD Inc, subject to license 20080407P00.




--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|

Re: How to pass parameters to a windows application

Dave Hylands
Hi Jason,

On Sun, Aug 1, 2010 at 5:43 PM, Jason Pyeron <[hidden email]> wrote:
> I am at my wits end trying to figure out how to execute this in bash
>
> C:\WINDOWS>cmd /c "start "" "C:\Documents and Settings\All
> Users\Desktop\projects\crisfield\trunk\etc""

Based on your prompt, I'd say that you're not in bash.

cmd /c start "c:\Documents and Settings\"

works for me. From the cmd prompt,

cmd /c "start "c:\Documents and Settings""

works. I wrote a little program called open,
http://www.davehylands.com/Software/Open/

which opens files the same way as double clicking on them. It also
translates cygwin paths into Win32 paths if you build the cygwin
version.
If passed a directory name, it does the same as choosing "Explore".

--
Dave Hylands
Shuswap, BC, Canada
http://www.DaveHylands.com/

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|

Re: How to pass parameters to a windows application

Andy Koppe
On 2 August 2010 07:49, Dave Hylands wrote:

>
> On Sun, Aug 1, 2010 at 5:43 PM, Jason Pyeron wrote:
>> I am at my wits end trying to figure out how to execute this in bash
>>
>> C:\WINDOWS>cmd /c "start "" "C:\Documents and Settings\All
>> Users\Desktop\projects\crisfield\trunk\etc""
>
> Based on your prompt, I'd say that you're not in bash.
>
> cmd /c start "c:\Documents and Settings\"
>
> works for me. From the cmd prompt,
>
> cmd /c "start "c:\Documents and Settings""
>
> works. I wrote a little program called open,
> http://www.davehylands.com/Software/Open/
>
> which opens files the same way as double clicking on them. It also
> translates cygwin paths into Win32 paths if you build the cygwin
> version.
> If passed a directory name, it does the same as choosing "Explore".

You should both have a look at 'cygstart'.

Andy

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|

Re: How to pass parameters to a windows application

Harald Joerg-2
Andy Koppe <[hidden email]> writes:

> On 2 August 2010 07:49, Dave Hylands wrote:
>>
>> On Sun, Aug 1, 2010 at 5:43 PM, Jason Pyeron wrote:
>>> I am at my wits end trying to figure out how to execute this in bash
>>>
>>> C:\WINDOWS>cmd /c "start "" "C:\Documents and Settings\All
>>> Users\Desktop\projects\crisfield\trunk\etc""
>>
>> Based on your prompt, I'd say that you're not in bash.
>>
>> cmd /c start "c:\Documents and Settings\"
>>
>> works for me. From the cmd prompt,
>>
>> cmd /c "start "c:\Documents and Settings""
>>
>> works. I wrote a little program called open,
>> http://www.davehylands.com/Software/Open/
>>
>> which opens files the same way as double clicking on them. It also
>> translates cygwin paths into Win32 paths if you build the cygwin
>> version.
>> If passed a directory name, it does the same as choosing "Explore".
>
> You should both have a look at 'cygstart'.

Good that I'm typing so slow.

I was about to explain a procedure of mine which almost does what Jason
Pyeron wants, approximately working in almost every case, containing
lots of quote-escaping tricks (and starting with "`cygpath -u $COMSPEC`"
instead of the plain cmd, just in case)...  and making a total fool of
myself, given that cygstart does it all in one sweep.

Thanks for the nudge, Andy!
--
Cheers,
haj

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|

RE: How to pass parameters to a windows application

Jason Pyeron
In reply to this post by Andy Koppe


--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-                                                               -
- Jason Pyeron                      PD Inc. http://www.pdinc.us -
- Principal Consultant              10 West 24th Street #100    -
- +1 (443) 269-1555 x333            Baltimore, Maryland 21218   -
-                                                               -
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
This message is copyright PD Inc, subject to license 20080407P00.

 

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Andy Koppe
> Sent: Monday, August 02, 2010 5:31
> To: [hidden email]
> Subject: Re: How to pass parameters to a windows application
>
> On 2 August 2010 07:49, Dave Hylands wrote:
> >
> > On Sun, Aug 1, 2010 at 5:43 PM, Jason Pyeron wrote:
> >> I am at my wits end trying to figure out how to execute
> this in bash
> >>
> >> C:\WINDOWS>cmd /c "start "" "C:\Documents and Settings\All
> >> Users\Desktop\projects\crisfield\trunk\etc""
> >
> > Based on your prompt, I'd say that you're not in bash.
> >
> > cmd /c start "c:\Documents and Settings\"
> >
> > works for me. From the cmd prompt,
> >
> > cmd /c "start "c:\Documents and Settings""
> >
> > works. I wrote a little program called open,
> > http://www.davehylands.com/Software/Open/
> >
> > which opens files the same way as double clicking on them. It also
> > translates cygwin paths into Win32 paths if you build the cygwin
> > version.
> > If passed a directory name, it does the same as choosing "Explore".
>
> You should both have a look at 'cygstart'.

Hint taken, do not write what already exists. Thanks

It does not play nice with unc paths. Starting by cmd.exe /c start path does.
Suggestions?


jpyeron@phoenix /projects/cdnetdb/private/fxiao/cdnet
$ cygstart .

jpyeron@phoenix /projects/cdnetdb/private/fxiao/cdnet
$ cygstart //host67/inst
Unable to start '\\?\UNC\host67\inst': There is no application associated with
the given file name extension.

jpyeron@phoenix /projects/cdnetdb/private/fxiao/cdnet
$ start //host67/inst
++ cygpath -wa //host67/inst
+ dir='\\host67\inst'
+ cd 'C:\WINDOWS'
+ cmd /c 'start  \\host67\inst'

jpyeron@phoenix /projects/cdnetdb/private/fxiao/cdnet
$ cygstart doc/design/

jpyeron@phoenix /projects/cdnetdb/private/fxiao/cdnet
$ cygstart test\ dir/

jpyeron@phoenix /projects/cdnetdb/private/fxiao/cdnet
$ cygstart ..

jpyeron@phoenix /projects/cdnetdb/private/fxiao/cdnet
$ pushd //host67/documents/
//host67/documents /projects/cdnetdb/private/fxiao/cdnet

jpyeron@phoenix //host67/documents
$ cygstart .
Unable to start '\\?\UNC\host67\documents': There is no application associated
with the given file name extension.

jpyeron@phoenix //host67/documents
$ start .
++ cygpath -wa .
+ dir='\\host67\documents'
+ cd 'C:\WINDOWS'
+ cmd /c 'start  \\host67\documents'

jpyeron@phoenix //host67/documents
$



--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|

RE: How to pass parameters to a windows application

Jason Pyeron
In reply to this post by Dave Hylands
 

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Dave Hylands
> Sent: Monday, August 02, 2010 2:50
> To: [hidden email]
> Subject: Re: How to pass parameters to a windows application
>
> Hi Jason,
>
> On Sun, Aug 1, 2010 at 5:43 PM, Jason Pyeron <[hidden email]> wrote:
> > I am at my wits end trying to figure out how to execute this in bash
> >
> > C:\WINDOWS>cmd /c "start "" "C:\Documents and Settings\All
> > Users\Desktop\projects\crisfield\trunk\etc""
>
> Based on your prompt, I'd say that you're not in bash.

Yes the first example was not bash, that was my reference for what I am trying
in bash.

>
> cmd /c start "c:\Documents and Settings\"
>
> works for me. From the cmd prompt,
>
> cmd /c "start "c:\Documents and Settings""
>
> works. I wrote a little program called open,
> http://www.davehylands.com/Software/Open/
>
> which opens files the same way as double clicking on them. It
> also translates cygwin paths into Win32 paths if you build
> the cygwin version.
> If passed a directory name, it does the same as choosing "Explore".
>
> --
> Dave Hylands
> Shuswap, BC, Canada
> http://www.DaveHylands.com/
>
> --
> Problem reports:       http://cygwin.com/problems.html
> FAQ:                   http://cygwin.com/faq/
> Documentation:         http://cygwin.com/docs.html
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
>


--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-                                                               -
- Jason Pyeron                      PD Inc. http://www.pdinc.us -
- Principal Consultant              10 West 24th Street #100    -
- +1 (443) 269-1555 x333            Baltimore, Maryland 21218   -
-                                                               -
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
This message is copyright PD Inc, subject to license 20080407P00.



--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|

Re: How to pass parameters to a windows application

Andrey Repin-3
In reply to this post by Jason Pyeron
Greetings, Jason Pyeron!

> I am at my wits end trying to figure out how to execute this in bash

C:\WINDOWS>>cmd /c "start "" "C:\Documents and Settings\All
> Users\Desktop\projects\crisfield\trunk\etc""

> jpyeron@phoenix /projects/crisfield
> $ cmd /c "\"start \"\" \"C:\\Documents and Settings\\All
> Users\\Desktop\\projects\\crisfield\\trunk\\etc\"\""
> The filename, directory name, or volume label syntax is incorrect.

$ cmd /c start "" "C:/Documents and Settings/All Users/Desktop/projects/crisfield/trunk/etc"

Windows support both (more precise would be "see no difference between) "/"
and "\" as directory separators. Since DOS 3.3 at least.


--
WBR,
 Andrey Repin ([hidden email]) 02.08.2010, <19:51>

Sorry for my terrible english...


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|

Re: How to pass parameters to a windows application

Dave Hylands
In reply to this post by Jason Pyeron
Hi Jason,

>> You should both have a look at 'cygstart'.
>
> Hint taken, do not write what already exists. Thanks
>
> It does not play nice with unc paths. Starting by cmd.exe /c start path does.
> Suggestions?

My open utility plays nice with UNC paths...

I think I wrote open many many years ago (before I even started using
cygwin) and I've just been carrying it around with me. I added cygwin
path support when I started using cygwin.

I've added an alias to alias open to cygstart (I use gnome-open under Ubuntu).

Thanks for the tip.

--
Dave Hylands
Shuswap, BC, Canada
http://www.DaveHylands.com/

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|

Re: How to pass parameters to a windows application

Csaba Ráduly
In reply to this post by Jason Pyeron
On Mon, Aug 2, 2010 at 2:43 AM, Jason Pyeron  wrote:
> I am at my wits end trying to figure out how to execute this in bash
>
> C:\WINDOWS>cmd /c "start "" "C:\Documents and Settings\All
> Users\Desktop\projects\crisfield\trunk\etc""
>
> jpyeron@phoenix /projects/crisfield
> $ cmd /c "\"start \"\" \"C:\\Documents and Settings\\All
> Users\\Desktop\\projects\\crisfield\\trunk\\etc\"\""
> The filename, directory name, or volume label syntax is incorrect.
(snip)

cygstart was already suggested; if it doesn't help, try single quotes :
$ cmd /c start 'C:\Documents and Settings\All Users\...'

Bash uses backslashes as the escape character so \trunk ends up as <TAB>runk.
Single quotes prevent bash from interpreting backslashes and spaces.

--
Life is complex, with real and imaginary parts.
"Ok, it boots. Which means it must be bug-free and perfect. " -- Linus Torvalds
"People disagree with me. I just ignore them." -- Linus Torvalds

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|

Re: How to pass parameters to a windows application

Andy Koppe
In reply to this post by Jason Pyeron
On 2 August 2010 12:56, Jason Pyeron wrote:

>> 'cygstart'.
>
> It does not play nice with unc paths. Starting by cmd.exe /c start path does.
> Suggestions?
>
>
> jpyeron@phoenix /projects/cdnetdb/private/fxiao/cdnet
> $ cygstart .
>
> jpyeron@phoenix /projects/cdnetdb/private/fxiao/cdnet
> $ cygstart //host67/inst
> Unable to start '\\?\UNC\host67\inst': There is no application associated with
> the given file name extension.

It's a bug.

Cygstart uses cygwin_conv_path to convert to a Windows path, which
produces UNC paths for network paths. Trouble is, the ShellExecute
API, which is used to do the actual opening, doesn't appear to support
UNC paths.

Cygpath already turns '\\?\UNC\' at the start of a path into plain ol
'\\' (unless the resulting path would be longer than MAX_PATH, in
which case the UNC path is mandatory). Mintty does the same thing when
a file is opened with Ctrl+click.

So cygstart would need to do the same. And mkshortcut too (because the
APIs involved in creating shortcuts have trouble with long paths too).
Basically, any program that passes a path converted with
cygwin_conv_path to Windows APIs might have this issue.

Therefore I'm wondering whether it wouldn't be better to address this
once and for all in cygwin_conv_path itself by doing what cygpath
does: assuming the resulting path fits into MAX_PATH, drop "\\?\" from
all long paths and turn "UNC\" into "\\".

Andy

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|

Re: How to pass parameters to a windows application

Andy Koppe
In reply to this post by Dave Hylands
On 3 August 2010 00:17, Dave Hylands wrote:
>> [cygstart] does not play nice with unc paths.
>> Starting by cmd.exe /c start path does.
>> Suggestions?
>
> My open utility plays nice with UNC paths...

... because it uses cygwin_posix_to_win32_path_list(), which doesn't
produce paths starting with '\\?\UNC\' instead of '\\'. That function
is deprecated for Cygwin 1.7 though, because it doesn't support
Unicode or paths longer than MAX_PATH.

Andy

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|

Re: How to pass parameters to a windows application

Corinna Vinschen-2
In reply to this post by Andy Koppe
On Aug  3 12:26, Andy Koppe wrote:

> On 2 August 2010 12:56, Jason Pyeron wrote:
> >> 'cygstart'.
> >
> > It does not play nice with unc paths. Starting by cmd.exe /c start path does.
> > Suggestions?
> >
> >
> > jpyeron@phoenix /projects/cdnetdb/private/fxiao/cdnet
> > $ cygstart .
> >
> > jpyeron@phoenix /projects/cdnetdb/private/fxiao/cdnet
> > $ cygstart //host67/inst
> > Unable to start '\\?\UNC\host67\inst': There is no application associated with
> > the given file name extension.
>
> It's a bug.
>
> Cygstart uses cygwin_conv_path to convert to a Windows path, which
> produces UNC paths for network paths. Trouble is, the ShellExecute
> API, which is used to do the actual opening, doesn't appear to support
> UNC paths.
>
> Cygpath already turns '\\?\UNC\' at the start of a path into plain ol
> '\\' (unless the resulting path would be longer than MAX_PATH, in
> which case the UNC path is mandatory). Mintty does the same thing when
> a file is opened with Ctrl+click.
>
> So cygstart would need to do the same. And mkshortcut too (because the
> APIs involved in creating shortcuts have trouble with long paths too).
> Basically, any program that passes a path converted with
> cygwin_conv_path to Windows APIs might have this issue.

It's a shame that not even the official Win32 APIs are always clean
in terms of the long path name definition.

> Therefore I'm wondering whether it wouldn't be better to address this
> once and for all in cygwin_conv_path itself by doing what cygpath
> does: assuming the resulting path fits into MAX_PATH, drop "\\?\" from
> all long paths and turn "UNC\" into "\\".

This is already implemented in cygwin_conv_path for some time, but
only for the CCP_POSIX_TO_WIN_A case.  I never expected that this would
also be necessary for the wide char case.  Anyway, I applied a matching
patch.  As long as the resulting wide char path is not longer than
MAX_PATH, it will be stripped of the long path prefix.


Corinna

--
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|

Re: How to pass parameters to a windows application

Andy Koppe
On 4 August 2010 12:26, Corinna Vinschen wrote:
> It's a shame that not even the official Win32 APIs are always clean
> in terms of the long path name definition.

Yep, and MSDN doesn't even seem to mention it.

>> Therefore I'm wondering whether it wouldn't be better to address this
>> once and for all in cygwin_conv_path itself by doing what cygpath
>> does: assuming the resulting path fits into MAX_PATH, drop "\\?\" from
>> all long paths and turn "UNC\" into "\\".
>
> This is already implemented in cygwin_conv_path for some time, but
> only for the CCP_POSIX_TO_WIN_A case.  I never expected that this would
> also be necessary for the wide char case.  Anyway, I applied a matching
> patch.  As long as the resulting wide char path is not longer than
> MAX_PATH, it will be stripped of the long path prefix.

Great. Seems to be working fine for me.

This allows dropping the equivalent hack from cygpath, doesn't it?

Andy

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|

Re: How to pass parameters to a windows application

Corinna Vinschen-2
On Aug  4 20:40, Andy Koppe wrote:

> On 4 August 2010 12:26, Corinna Vinschen wrote:
> > It's a shame that not even the official Win32 APIs are always clean
> > in terms of the long path name definition.
>
> Yep, and MSDN doesn't even seem to mention it.
>
> >> Therefore I'm wondering whether it wouldn't be better to address this
> >> once and for all in cygwin_conv_path itself by doing what cygpath
> >> does: assuming the resulting path fits into MAX_PATH, drop "\\?\" from
> >> all long paths and turn "UNC\" into "\\".
> >
> > This is already implemented in cygwin_conv_path for some time, but
> > only for the CCP_POSIX_TO_WIN_A case.  I never expected that this would
> > also be necessary for the wide char case.  Anyway, I applied a matching
> > patch.  As long as the resulting wide char path is not longer than
> > MAX_PATH, it will be stripped of the long path prefix.
>
> Great. Seems to be working fine for me.
>
> This allows dropping the equivalent hack from cygpath, doesn't it?

Right, but it doesn't hurt either.


Corinna

--
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple