Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Thursday, November 13, 2008 10:33 PM
I know that you can run a DOS command program with the RUN command but, can you (call, shell, or run) an application that runs in windows from FoxPro? It's just a small program with a .exe but it was installed into windows.
Thanks
Friday, November 14, 2008 6:48 AM ✅Answered
You can try this.
FullCommand = "yourexe.exe " +"argument"
oWinshl = createobject ("Wscript.shell")
shl_res = oWinshl.Run(FullCommand, 1, .t.)
Ensure scripting host is installed.
Friday, November 14, 2008 11:12 AM ✅Answered
ShellExecute doesn't display error but return error codes. If it succeeds return code is > 32.
...\.exe is the executable and fpic is the parameter ( and there might also be a "Working-Start In Folder" parameter)
Code Snippet
fpic= Getfile('JPG')
lcExecutable = "c:\myillistrated\GRAPHICS\cards\Master\PhotoResize246x345.exe"
declare long ShellExecute in "shell32.dll" ;
long hwnd, string lpszOp, ;
string lpszFile, string lpszParams, ;
string lpszDir, long nShowCmd
fpic = TextMerge( '"<< m.fpic >>"') && Adding double quotes
lcExecutable = TextMerge('"<< m.lcExecutable >>"')
ShellExecute(0,"",m.lcExecutable, m.fpic,0,1)
Here is another sample:
Code Snippet
ShellExecute(0,'','c:\fpd26\foxprox.exe','mytest.prg','c:\fpd26',0)
Calling FoxProX.exe with myTest.prg as input parameter and working folder is c:\Fpd26. Run it but do not show a window (last parameter 0-window style Do not show). It would be equivalant to doing this in a DOS prompt (except last do not show):
c:
cd\fpd26
foxprox "mytest.prg"
Or invloking a shortcut where:
Target: c:\fpd26\foxprox.exe myStart.prg
Start in: c:\fpd26
If the exe or parameter has spaces in path then needs to be surrounded by doublequotes. Better surround if has spaces or not.
Saturday, November 15, 2008 11:03 AM ✅Answered
Now that is your fault You didn't specify the version before and you know what, I was afraid that the version you are using might be older than VFP7 but thought oh no not at his time
TextMerge() is a built in function from VFP7 and up. It is an inline version of what textmerge does. Anyway actually I was lazy and used it to add doublequotes to exe and picture filenames instead of using string concat. You can fix like this:
Code Snippet
fpic = '"' + m.fpic + '"'
lcExecutable = '"' + m.lcExecutable + '"'
Thursday, November 13, 2008 10:42 PM
Process.Start("iexplore.exe")
A.D.T.
Thursday, November 13, 2008 11:03 PM
Process.Start("iexplore.exe") Generates an object "PROCESS not found error
Thursday, November 13, 2008 11:19 PM
Process.Start() has nothing to do with VFP. To use .Net classes you need extra stuff.
Code Snippet
run /n yourwindows.exe
Or you can use the ShellExecute winAPI call. ie:
Code Snippet
declare long ShellExecute in "shell32.dll" ;
long hwnd, string lpszOp, ;
string lpszFile, string lpszParams, ;
string lpszDir, long nShowCmd
* Open the file
* wiindows determines the exe to open with
ShellExecute(0,'Open','c:\my folder\myDocument.doc',0,0,1)
ShellExecute(0,'','c:\My Folder\MyWindowsApp.exe',0,0,1)
Friday, November 14, 2008 1:48 AM
Thanks for your input.
run /n yourwindows.exe works great Thanks sooo much!
I also need to run an application that has a file attached to it. This file is gotten with a GETFILE() and saved in a variable called fpic. I tried the following code but it didn't work.
fpic= Getfile('JPG')
declare long ShellExecute in "shell32.dll" ;
long hwnd, string lpszOp, ;
string lpszFile, string lpszParams, ;
string lpszDir, long nShowCmd
fpic1 = "c:\myillistrated\GRAPHICS\cards\Master\PhotoResize246x345.exe " + fpic
ShellExecute(0,'',fpic1,0,0,1)
I didn't get an error but the program (PhotoResize246x345.exe) didn't produce any output
Friday, November 14, 2008 5:21 PM
I am really amazed as to how patient everyone is in reguards to my questions. Thanks for your professional attitude.
Because I must use a Getfile() which returns a string variable, it just does not want to work. I am not quit sure what TextMerge( '"<< m.fpic >>"') does but it causes an error "TextMerge.prg Does Not Exist"
If I use run c:\myillistrated\GRAPHICS\cards\Master\PhotoResize246x345.exe filename.jpg
it works just fine. However, filename.jpg should be obtained from the getfile() command because it is never the same file or even the same filepath.
I am running FoxPro 6.0 Professional Edition. I don't know if I am maybe missing the textmerge feature.
Thanks once again.