0

I want to call one command(user defined) from C program(Windows). Can you tell me the function available?

paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953
Pradeep
  • 3,420
  • 11
  • 35
  • 38

1 Answers1

2

system() is the simplest way to call external programs.

It's a matter of doing something like:

system ("runme.exe");

The Win32 API has a lot of process control calls as well, which give you better control and monitoring. Look for CreateProcess and its brethren.

paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953
  • you can pass complete path to system(). In the above case i.e `system("runme.exe")` runme.exe must be present in current folder or in the system path (defined by PATH environment variable). But if your exe resides at some other place, you can specify complete path to it in system() call e.g `system("c:\path\to\file\runme.exe")` – binW Jul 19 '10 at 07:54
  • My opinion on system(): http://stackoverflow.com/questions/2923843/can-i-use-boost-library-for-crossplatform-application-executing/2925579#2925579 tl,dr version: avoid it. – Matteo Italia Jul 19 '10 at 08:57