Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using Run command with variable 1

Status
Not open for further replies.

sfetr

Programmer
Jun 9, 2006
5
PL
Hi,

I have already made an OLE document tree, but I would like to add another interesting thing - make the program run Windows's Explorer with the directory of selected file.

I tried to use "Run" command, but I guess, that I have problem with passing the variable:

Code:
abcd = "c:\program files\"
run /n explorer (m.abcd)

It generates MessageBox with info, that path doesn't exist or doesn't specify directory.

What should I change or use instead?

sfetr
 
Code:
abcd = "run /n explorer c:\program files\"
&abcd

I prefer to use ShellExecute:

Code:
DECLARE INTEGER ShellExecute IN SHELL32.DLL INTEGER nWinHandle,;
                                            STRING cOperation,;
                                            STRING cFileName,;
                                            STRING cParameters,;
                                            STRING cDirectory,;
                                            INTEGER nShowWindow
result = ShellExecute(0, 'open', [explorer.exe], [c:\program files\], [], 1)

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
 
Solution:

Code:
abcd = "run /n explorer c:\program files\"
&abcd

doesn't satisfy me. I have plenty of files to use it with. Actually, I often don't even know names of these files - this is why I wrote about passing names as variables.

I tried to modify the second case, but after doing .prg I obtained info, that function name is missing.

sfetr
 
OK, try this then:
Code:
abcd = [c:\Program files\]
run_command = [RUN /N explorer ]+abcd
&run_command


Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
 

Sfetr,

I tried to modify the second case, but after doing .prg I obtained info, that function name is missing.

Borislav's ShellExecute suggestion will work much better than RUN. The reason for the error message might be that you used the wrong casing. The ShellExeucte function name is case-sensitive.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top