Run a program file in Visual Foxpro using VB.NET

G

Guest

I have a abc.PRG file in visual foxpro 8.0. I can run this file using visual
foxpro environment and it creates a table X.dbf in the same folder where this
program file is and populates some data in the table.
I want a way to run this abc.PRG file through VB.net environment.
(Equivalent method to perform same as "DO abc.prg" command in foxpro).
Please help me. Thanks in advance.
 
B

Bernie Yaeger

Hi Amar,

If you can figure out the string that runs the program - eg,
"c:\fox\foxpro.exe abc.prg" - then you can call it like this:

Dim psi As New ProcessStartInfo

psi.UseShellExecute = True

psi.FileName = "c:\fox\foxpro.exe abc.prg"

Process.Start(psi)

But bear in mind that this is using the services of foxpro to run the .prg
file - and I don't think there is any way you can avoid this - in other
words, you would have to install foxpro on any machine that runs this prg
file.

HTH,

Bernie Yaeger
 
C

Cindy Winegarden

Hi Amar,

Here's another way, and as Bernie said, this assumes VFP is installed on the
machine. Otherwise you'll need a VFP exe and the appropriate runtimes
installed.

'-- Add a reference to the Visual FoxPro Type Library
'-- I'm using VFP 9 so the reference points to
'-- C:\Program Files\Microsoft Visual FoxPro 9\VFP9.exe
'-- Assume program TestAutomation.prg in C:\Temp

Module Module1
Sub Main()
'-- Intellisense with bring up the VFP properties and methods
Dim Fox As New VisualFoxpro.FoxApplication
Fox.DefaultFilePath = "C:\Temp"
Fox.DoCmd("Do TestAutomation.prg")
End Sub
End Module
 
G

Guest

Thank you Cindy. You are my hero!!
Bernie thank you so much too. Both of your are awesome. Thanks again!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top