[Jprogramming] Open file with associated application

Devon McCormick devonmcc at gmail.com
Thu Jul 12 00:02:37 HKT 2007


Ric -

I don't know how portable these are, but both of these work for me:

1) use "task":
   load 'task'
   shell_jtask_ '"C:\amisc\A name with embedded spaces.xls"'

2) write the command to a batch file and run that:
   '"C:\amisc\A name with embedded spaces.xls"' fwrite
'c:\amisc\runnwes.bat'
42
   wd 'winexec "cmd /C c:\amisc\runnwes.bat" sw_hide'
0

Good luck,

Devon

On 7/11/07, Sherlock, Ric <R.G.Sherlock at massey.ac.nz> wrote:
>
> wd 'winexec *start "path/to/file"'
> doesn't work for me.
>
> The following does, but suffers from the same problem as I had before.
>   wd 'winexec "cmd.exe /C start ',filename,'" sw_hide'
>
> I have looked through past posts in the forum but can't find an answer
> to my original question.
> I can open a filename containing spaces if I explicitly name the
> application that I want to run:
>
> wd 'winexec "C:\Program Files\Microsoft Office\OFFICE11\excel.exe"
> "drive:/path to/file"'
>
> but if I want to "open a file with the application associated with that
> file extension" then I haven't found an answer yet.
>
> > [mailto:programming-bounces at jsoftware.com] On Behalf Of Oleg Kobchenko
> > You could try
> >
> >   wd 'winexec *start "path/to/file"'
> >
> > See also in forum earlier.
> >
> >
> > On Jul 11, 2007, at 3:15 AM, "Sherlock, Ric"
> > <R.G.Sherlock at massey.ac.nz> wrote:
> >
> > I want to open a file with the application associated with
> > that file extension.
> > E.g. I have an Excel file (*.xls) and I want to open it in Excel.
> >
> > If the file name doesn't contain any spaces then the
> > following works on Windows.
> >
> > wd 'winexec "cmd /C ',filename,'" sw_hide'
> >
> > How can I accomplish something similar if the file name
> > contains spaces?
> >
> > Is it possible to come up with a platform agnostic version?
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
> >
> >
> >
> > ______________________________________________________________
> > ______________________
> > Moody friends. Drama queens. Your life? Nope! - their life,
> > your story. Play Sims Stories at Yahoo! Games.
> > http://sims.yahoo.com/
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>



-- 
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail


More information about the Programming mailing list