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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run EXE syntax

Status
Not open for further replies.

rmcmorris

Programmer
Nov 22, 2002
42
US
I picked up a thread a few months ago about using a "Runner" EXE file to check for updates, and a "Main" EXE file which is the main application. I finally decided to implement this approach with the EXEs local to the users' machines. We have a feature in the app which allows me to close the app on all machines, but as we add more users, this is becoming disruptive.

I have everything worked out now the runner works fine, except that I am having some syntax trouble calling up MAIN.EXE.

If I hard code everything like:

Run /N C:\Program Files\MyApp\MAIN.EXE
Quit **THis closes the Runner App

This code works great, but I do not like the idea of hard-coding the EXE.

If I try to make the EXE Path/filename a variable like:

mainprog='C:\Program Files\MyApp\MAIN.EXE'
Run /N MainProg
Quit **THis closes the Runner App

The thing crashes when it trys to run the variable. Any way to use a variable with RUN???

Thanks,

Regan
 
With your sample syntax, have you tried RUN /N &MainProg?

Peping
 
Regan:

Have you tried:

CD C:\Program Files\MyApp
DO MAIN.EXE

...this will work, assuming MAIN.EXE is a compiled VFP executable.

Al
 
AllanB1

CD C:\Program Files\MyApp

This will give an error.

It should read:
CD "C:\Program Files\MyApp"
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Peping,

Thanks your suggestion of:

RUN /N &MainProg

Works Great!!

MGagNon and AllanB1, Trouble with Do command is that the runner app will need to wait for the Main app to close before the Quit command is executed. This causes many problems in my Main app which issues commands such as CLEAR, etc.

Therefore, the RUN command opens MAIN.EXE and then the code in RUNNER continues to execute, thereby closing itself.

Regan
 
AllanB1

Actually I'm totally shocked. This would be a first for me after 14 years to see someone using a path with a space in the middle without quotes and without getting are error message. Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Mike,

Not using any quotes with the space also works for my system. I am using VFP 7.0 with SP1.

Regan
 
VFP7.0 SP1 WinXP (OS maybe?)
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
AllanB1,

Are your sure changing directory in VFP to "Program Files" WITH SPACE works on your system?

Peping
 
Regan:

You are correct, full control is passed to the called program using DO, as it would be when calling any VFP procedure.

Glad you found your solution.

Al
 
Mike,

My OS is Win2000 Pro. VFP 7.0 SP1.

This most definately works on my system:

RUN /N C:\Program Files\MyApp\MAIN.EXE

Absolutely no quotation marks involved. In fact, If I had single quotation marks, and try to execute, I get this error:

"Run|! Command Failed."

If I use Double Quotations or NO QUOTATIONS, the command runs just fine.

Regan
 
Mike/Peping:

My oversight. Mike, I initially thought you were referring to the CD command, in general, needing "".

Peping, thanks for questioning again. Of course, as at the DOS prompt, if there are spaces within the path, quotes are needed.

One of those days...

Al
 
tcRun = "Run /N 'C:\Program Files\MyApp\MAIN.EXE'"
&tcRun

Try it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top