# Odd question.. but cna you get C to run an app?

This is a discussion on Odd question.. but cna you get C to run an app? within the C Programming forums, part of the General Programming Boards category; Is there a way for you to code program like on a modern computer.. where C is typically in the ...

1. ## Odd question.. but cna you get C to run an app?

Is there a way for you to code program like on a modern computer.. where C is typically in the console to open an application.. just to make an example everyone will know.. like get C to open I.E. or something like that??

2. Yes, have a look at the FAQ here.

It's quite natural that this HAS TO BE POSSIBLE, because the shell/command prompt is actually written in C - so it has to be able to run another program. The same applies for whatever application is responsible for displaying your desktop, start-menu or whatever is your graphical user-interface - it's all written in C (or C++).

--
Mats

3. If you're on Windows, have a look at CreateProcess or ShellExecute

4. I know a good example
I had written something similar to what you are describing to make my desktop less cluttered.
There is a way that I know of :
Code:
system("start iexplore.exe");
You have to know the name of it's process. That is in Windows by the way.
It can run anything in the system32 folder, and anything in the same folder as your executable.

5. It can run anything in the system32 folder, and anything in the same folder as your executable.
Wrong. It can run any program contained in the paths specified in its PATH environment variable.

6. Thanks for correcting me Happy Reaper,
I learn something new every day...

7. Originally Posted by Happy_Reaper
Wrong. It can run any program contained in the paths specified in its PATH environment variable.
I wasn't aware that the C standard dictates any such thing. The system() function simply invokes the program exactly as specified by calling an appropriate "shell."

8. I never meant the standard. In windows, calling system('cmd') will work for any command located in one of the paths specified in the PATH environment variable.

9. Originally Posted by Happy_Reaper
I never meant the standard. In windows, calling system('cmd') will work for any command located in one of the paths specified in the PATH environment variable.
What I was getting at, though, is that the REASON that works is because system() invokes a "shell" -- it's this shell which looks through the PATH, not system() itself.

10. Originally Posted by Happy_Reaper
I never meant the standard. In windows, calling system('cmd') will work for any command located in one of the paths specified in the PATH environment variable.
I'm not familiar with Windows, but can't you run ANY command by specifying the full path of the executable (i.e., C:\foo\bar\cmd.exe)?

11. It might just be me, but we are a bit off of the original purpose of this thread.

Regarding robatino's post :
You can start a few things, but I think they have to be .exe
hmm...
There was a comand for that, (or was that in cygwin?) I think basically, you have to open things that are not .exe with a program.
example :
OR
iexplore "C:\html\webpage.html"

But I am not sure.

12. That's not what I'm talking about - "notepad" and "iexplore" are executables, the arguments you give them ("C:\textfiles\text.txt" or "C:\html\webpage.html") aren't. You should be able to run the executables by giving their full path (I don't know offhand what those are) without relying in it being in PATH.

13. ...Run the executables..?
you mean like :

I don't think I am understanding what you are saying.
"run the executables by giving their full path without relying in it being in PATH"
What?

14. Code:
#include <stdio.h>
#include <stdlib.h>
int main ( ) {
}