calling other programs from my program 
Author Message
 calling other programs from my program

Hello all,

Suppose I write a program in which upon termination of the program I
want it to run or call another program.  How would I go about doing
this?

Say for example  my program is prog.exe and after it's done it's job I
want it to call another program (whose location on the hard drive I
know) called prog2.exe.

The program that prog.exe calls is not written by me and I don't have
the source code either so I just need to call it.

Thanks for your help,
RR



Wed, 05 Jan 2000 03:00:00 GMT  
 calling other programs from my program

Quote:

> Hello all,

> Suppose I write a program in which upon termination of the program I
> want it to run or call another program.  How would I go about doing
> this?

> Say for example  my program is prog.exe and after it's done it's job I
> want it to call another program (whose location on the hard drive I
> know) called prog2.exe.

> The program that prog.exe calls is not written by me and I don't have
> the source code either so I just need to call it.

Look at system().

Michael M Rubenstein



Thu, 06 Jan 2000 03:00:00 GMT  
 calling other programs from my program



Quote:
> Hello all,

> Suppose I write a program in which upon termination of the program I
> want it to run or call another program.  How would I go about doing
> this?

> Say for example  my program is prog.exe and after it's done it's job I
> want it to call another program (whose location on the hard drive I
> know) called prog2.exe.

> The program that prog.exe calls is not written by me and I don't have
> the source code either so I just need to call it.

> Thanks for your help,
> RR

1.      If you could modify prog.exe, you could add a call to a spawn... or
exec... function, if your compiler and operating system supported them.

2.      You can write your own program which uses a spawn... or exec... function
to run prog.exe,
with a parameter indicating that your program waits for the exit code of
prog.exe, meaning that prog.exe has finished running and then use another
spawn... or exec... function to run prog2.exe.  Again, this is if your
compiler and OS support these functions.  (Since you are talking about .exe
files, I assume you are talking DOS or Windows, but you did not specify).

3.      You can use a batch file or shell script to run prog.exe, then
prog2.exe.

Also:  I don't know if there are any standards in this regard, but your
user name strikes me as rude.  Please use a name or a nick-name.

--

Jack Klein

All views expressed in this message are mine,
and not necessarily that of my company or any
of our clients.



Fri, 07 Jan 2000 03:00:00 GMT  
 calling other programs from my program


scribbled :

Quote:
>Hello all,

>Suppose I write a program in which upon termination of the program I
>want it to run or call another program.  How would I go about doing
>this?

>Say for example  my program is prog.exe and after it's done it's job I
>want it to call another program (whose location on the hard drive I
>know) called prog2.exe.

>The program that prog.exe calls is not written by me and I don't have
>the source code either so I just need to call it.

>Thanks for your help,
>RR

I did this in one of my programs (it swaps PROGMAN.INI to create custom
desktops, then calls WIN.COM)

You need to use system() - but remember, if this is DOS, you need to
write a backslash (\) as (\\) - it's

system("c:\\windows\\win.com");   - not system("c:\windows\win.com");

You could use exec() or spawn() but those can be a PITA. system() is
much nicer. Also, with system() and DJGPP, your program stays in memory.

A snippet of source :

system("copy user.dsk c:\\windows\\progman.ini");
system("c:\\windows\\win.com");
reboot();

reboot() is written by me, there is no reboot function normally.
To reboot, just call INT 19 (although there are better methods, one of
which I use)

--
Revised anti-spam in use : remove X to reply -
'Xnetbook' becomes 'netbook'

Anti-spam thermonuclear warheads cheap at only $300!



Fri, 07 Jan 2000 03:00:00 GMT  
 calling other programs from my program

Thanks you've been the most help so far.  I just have a question
though...you said that to reboot from a program you used reboot() which
was written by you.  How would I go about writing my own function to
reboot?  I am new to programming in C so please keep it fairly simple.

Thanks,
Russ

Quote:


> scribbled :
> >Hello all,

> >Suppose I write a program in which upon termination of the program I
> >want it to run or call another program.  How would I go about doing
> >this?

> >Say for example  my program is prog.exe and after it's done it's job
> I
> >want it to call another program (whose location on the hard drive I
> >know) called prog2.exe.

> >The program that prog.exe calls is not written by me and I don't have

> >the source code either so I just need to call it.

> >Thanks for your help,
> >RR

> I did this in one of my programs (it swaps PROGMAN.INI to create
> custom
> desktops, then calls WIN.COM)

> You need to use system() - but remember, if this is DOS, you need to
> write a backslash (\) as (\\) - it's

> system("c:\\windows\\win.com");   - not system("c:\windows\win.com");

> You could use exec() or spawn() but those can be a PITA. system() is
> much nicer. Also, with system() and DJGPP, your program stays in
> memory.

> A snippet of source :

> system("copy user.dsk c:\\windows\\progman.ini");
> system("c:\\windows\\win.com");
> reboot();

> reboot() is written by me, there is no reboot function normally.
> To reboot, just call INT 19 (although there are better methods, one of

> which I use)

> --
> Revised anti-spam in use : remove X to reply -
> 'Xnetbook' becomes 'netbook'

> Anti-spam thermonuclear warheads cheap at only $300!



Fri, 07 Jan 2000 03:00:00 GMT  
 calling other programs from my program

Quote:

> You need to use system() - but remember, if this is DOS, you need to
> write a backslash (\) as (\\) - it's

> system("c:\\windows\\win.com");   - not system("c:\windows\win.com");

> You could use exec() or spawn() but those can be a PITA. system() is
> much nicer. Also, with system() and DJGPP, your program stays in memory.

"system()" also has the advantage of being a standard C function (with
an implementation specific argument), whereas "exec()" or "spawn()" are
not standard C and are unknown on most C compilers.

Stephan
(initiator of the campaign against grumpiness in c.l.c)



Sun, 09 Jan 2000 03:00:00 GMT  
 calling other programs from my program

Quote:

>Suppose I write a program in which upon termination of the program I
>want it to run or call another program.  How would I go about doing
>this?

>Say for example  my program is prog.exe and after it's done it's job I
>want it to call another program (whose location on the hard drive I
>know) called prog2.exe.

This depends on your platform, which you did not specify.  On a DOS or UNIX
computer, you could simply write a batch file or script that runs both
prog.exe and prog2.exe, one immediately after the other:

        prog
        prog2

Perhaps you could have prog.exe stuff the keyboard buffer with the text
"prog2" just before it terminates, thus invoking the second program.
Again, this is platform-specific and really has nothing to do with standard
C.  Try asking in a newsgroup that discusses your specific OS and hardware,
such as



or whichever newsgroup may be more relevant.

--
Robert B. Clark
Visit ClarkWehyr Enterprises On-Line at http://www.iquest.net/~rclark/ClarkWehyr.html

[My e-mail address has been ROT-13'ed in order to combat spambots.]



Mon, 10 Jan 2000 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. trouble with giving my program to others

2. FS: C Programming and others CHEAP!

3. GA Multi Jobs/Fortune 100 and others/Unix,C,Lans,Programming

4. How to call a program from another program ?

5. Socket Programming (How to program a timeout mechanism on a read/write call)

6. call asm program from C program

7. Calling a CGI program from a C program

8. How to call perl program from C program ?

9. How do I Call a dos program from within my program

10. calling another program from within a program

11. Calling external programs from within MSVC++ programs on win955

12. Call a Java program from a C++ program?

 

 
Powered by phpBB® Forum Software