I kick off a BAT file from within my VFP7 app with something like this...

lcPath = "C:\MyPath"
lcFile = "MyFile.BAT"
CD (lcPath)
ShellExecute( 0, "open", lcFile, "", "", 2 )

All works OK.

However, if lcPath has a value of [\\MyPC\c\MyPath] the ShellExecute doesn't
seem to work.

SYS(5) + SYS(2003) return the expected value of [\\MyPC\c\MyPath] at that
point.
FILE(lcPath + "\" + lcFile) returns .t.

Any ideas?

Brian

Re: Running BAT file via ShellExecute by Andrew

Andrew
Wed Aug 09 02:53:33 CDT 2006

"Brian McKillop" <brian.nospamforme@mckillopassociates.com.au> wrote in
message news:BhfCg.9263$rP1.690@news-server.bigpond.net.au...
>I kick off a BAT file from within my VFP7 app with something like this...
>
> lcPath = "C:\MyPath"
> lcFile = "MyFile.BAT"
> CD (lcPath)
> ShellExecute( 0, "open", lcFile, "", "", 2 )
>
> All works OK.
>
> However, if lcPath has a value of [\\MyPC\c\MyPath] the ShellExecute
> doesn't seem to work.
>
> SYS(5) + SYS(2003) return the expected value of [\\MyPC\c\MyPath] at that
> point.
> FILE(lcPath + "\" + lcFile) returns .t.
>
> Any ideas?

Not sure why it doesn't work, I only have FPW which has no CD command and I
don't seem to be able to set default to a UNC.
I can ShellExecute path+file together though, what does

ShellExecute(0, 'open', lcPath+'\'+lcFile, '', '', 2)

do for you?

--
regards
Andrew Howell



Re: Running BAT file via ShellExecute by Brian

Brian
Wed Aug 09 06:17:02 CDT 2006

Andrew,

Nope. ShellExecute(0, 'open', lcPath+'\'+lcFile, '', '', 2) doesn't work for
me with a UNC path or otherwise.

I have to CD or SET DEFAULT to the path first.

Regards,

Brian

"Andrew Howell" <ajh@work> wrote in message
news:OYneuj4uGHA.4752@TK2MSFTNGP02.phx.gbl...
> "Brian McKillop" <brian.nospamforme@mckillopassociates.com.au> wrote in
> message news:BhfCg.9263$rP1.690@news-server.bigpond.net.au...
>>I kick off a BAT file from within my VFP7 app with something like this...
>>
>> lcPath = "C:\MyPath"
>> lcFile = "MyFile.BAT"
>> CD (lcPath)
>> ShellExecute( 0, "open", lcFile, "", "", 2 )
>>
>> All works OK.
>>
>> However, if lcPath has a value of [\\MyPC\c\MyPath] the ShellExecute
>> doesn't seem to work.
>>
>> SYS(5) + SYS(2003) return the expected value of [\\MyPC\c\MyPath] at that
>> point.
>> FILE(lcPath + "\" + lcFile) returns .t.
>>
>> Any ideas?
>
> Not sure why it doesn't work, I only have FPW which has no CD command and
> I don't seem to be able to set default to a UNC.
> I can ShellExecute path+file together though, what does
>
> ShellExecute(0, 'open', lcPath+'\'+lcFile, '', '', 2)
>
> do for you?
>
> --
> regards
> Andrew Howell
>



Re: Running BAT file via ShellExecute by Andrew

Andrew
Wed Aug 09 06:20:25 CDT 2006

"Brian McKillop" <brian.nospamforme@mckillopassociates.com.au> wrote in
message news:OujCg.9421$rP1.1918@news-server.bigpond.net.au...
> Andrew,
>
> Nope. ShellExecute(0, 'open', lcPath+'\'+lcFile, '', '', 2) doesn't work
> for me with a UNC path or otherwise.
>
> I have to CD or SET DEFAULT to the path first.

What return code does ShellExecute give?

Are you trying to pass any parameters?


It is definately working here, I made a batch file, I placed it on a network
share and I called ShellExecute with the UNC to the file. The only real
difference is that from FPW I'm having to use foxtools, Regfn and Callfn
instead of DECLARE ... ... to call ShellExecute.

Command line parameters *must* be passed to a separate parameter of
ShellExecute otherwise it will throw a "file not found" error.

--
HTH
Andrew Howell



Re: Running BAT file via ShellExecute by Brian

Brian
Wed Aug 09 15:50:27 CDT 2006


"Andrew Howell" <ajh@work> wrote in message
news:ugDMpX6uGHA.3552@TK2MSFTNGP03.phx.gbl...
>
> What return code does ShellExecute give?
>
> Are you trying to pass any parameters?
>
>

Andrew,

ShellExecute returns 2.
No parameters being passed.

Here's something interesting...

If I enter this in the command window..

CD ([\\MyPC\c\MyPath])
x=ShellExecute(0, 'open', 'test.bat', "", '', 2)

...the resulting DOS box says...

'\\MyPC\c\MyPath\'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.

This is obviously my problem.

Brian