Page 1 of 1

Newbie - RUNPROGRAM Question

Posted: Mon Dec 16, 2002 3:34 am
by ZaoCix
I'm new to the programming field, and I figured QBasic was prolly as easy as it gets to learn some stuff. I've a couple questions... I'm trying to figure out how to run a program with certain perimeters, inside my program.

It starts out with the user entering an IP address. Once entered, my program takes the ip variable ( IP$ ) and enters it into the RUNPROGRAM parameters for NBTSTAT, which I want to do something like this...

RUN nbtstat - A IP$

So that it runs NBTSTAT with the -A parameters and pops in the IP from the variable. Now, I know this is prolly far from correct, but i'm new in the programming world so. I'm having kind of a hard time even explaining.

???

Re: Newbie - RUNPROGRAM Question

Posted: Mon Dec 16, 2002 3:36 am
by ZaoCix
Oh and if someone gets the chance to answer could you happen to add some explanations so I can get a better idea of whats going on than simply telling me an answer  ;D thanks...

Re: Newbie - RUNPROGRAM Question

Posted: Mon Dec 16, 2002 3:22 pm
by frankiebaby
the problem is in the way qbasic's run statement works. it is designed to run a program without parameters. form the help on run:



 RUN "CATCHALL"

would execute CATCHALL.EXE from a BC-compiled program, and CATCHALL.BAS
from within QuickBASIC.

Programs running within the QuickBASIC environment must call only QuickBASIC program files. The file is loaded and run as if it were a QuickBASIC program; if it is not in the QuickBASIC program format, execution halts. The error message that appears varies, depending on the file's contents.


basically this says that if you are not compiling and running, in will not exucute a .exe file. then it is looking for a .BAS to run. so, what you must do is this:

use the shell command:


SHELL "what will go to dos prompt typed here"

or, in ur case

SHELL "nbtstat - A" + IP$

Re: Newbie - RUNPROGRAM Question

Posted: Wed Dec 18, 2002 10:48 pm
by Jehovah
if nbtstat is your program, don't forget to use "Command$" to get the parameters you gave using the shell$ command (yup, shell is the only way to go).