I am planning on making a program to so that when it is excecuted it carries out the following procedure in 1 go...
run command prompt ( system("CMD"); )...then use the command line to carry out the following command...

"C:\Program Files\PowerMenu\PowerMenu.exe" -hideself on

Im sure i have seen this done using "system();" but i cant get it to work...any ideas ?

I am planning on making a program to so that when it is excecuted it carries out the following procedure in 1 go...
run command prompt ( system("CMD"); )...then use the command line to carry out the following command...

"C:\Program Files\PowerMenu\PowerMenu.exe" -hideself on

Im sure i have seen this done using "system();" but i cant get it to work...any ideas ?

I now what you are trying to do. You want to open CMD, then withing CMD you want to execute the second command. Am I right? :) . If I'm right, then you need to find out whether you can pass any options to CMD when you call it. As of right now, the way you have it. You will call CMD first and wait for CMD to finish before you can execute the second command.

For example in linux, CMD = xterm(at least for me). So the way you will do it will be:

system("xterm -e second command");

I'm not sure whether CMD has that feature. There are other functions to execute external programs, some one posted them in the forum I remember, I just dont remember where. :o .Sorry. Try searching on the previous post in the forum, maybe you find the answer. Good Luck!


-r

you don't need to call cmd.exe explicitly -- the system() function will do that for you. All you have to do is tell system() what program you want to run

system("C:\Program Files\PowerMenu\PowerMenu.exe")

you don't need to call cmd.exe explicitly -- the system() function will do that for you. All you have to do is tell system() what program you want to run

system("C:\Program Files\PowerMenu\PowerMenu.exe")

Yea that makes more sense to me. Just call system like this:

system("C:\Program Files\PowerMenu\PowerMenu.exe -hideself on");

That should work. Good point Ancient Dragon. Good luck

-r

correction -- need to double-slash for the compiler.

system("C:\\Program Files\\PowerMenu\\PowerMenu.exe -hideself on");

Which compiler are you using, is it a windows one?

-r

yes windows xp dev c++...I will give it a go and feed you back...thanks for your help people :D

thanks, it worked fine except i had to adjust the command to look like this:

system("\"C:\\Program Files\\PowerMenu\\PowerMenu.exe\"-hideself on");

I had to do this because the actual command had to have " quote marks around the path, and the compiler needs a \ backslash to take the " as a character...lol you probably already know this, but i am just pointing it out lol.

Hi, I m new to all this..
I used system("mspaint"); in my c program.
After opening i want to continue with my other instructions.

Now what is happening...
The flow is being stopped at this command and the next instructions are only being executed when i close the mspaint...

Is there any way... tht as soon as the mspaint is opened my next instructions will start working...

Thanks guys...

gsb

>>Is there any way... tht as soon as the mspaint is opened my next instructions will start working...

Yes, use win32 api function CreateProcess() see MSDN for parameters and details. The description in MSDN may look a little overwhelming, but most of the parameters are 0.

>>Is there any way... tht as soon as the mspaint is opened my next instructions will start working...

Yes, use win32 api function CreateProcess() see MSDN for parameters and details. The description in MSDN may look a little overwhelming, but most of the parameters are 0.

Thanks a Lot...

hello friends
i am new to c and c++
can anyone say cleary how to execute a c program from c another program
thanks in advance..

commented: read the thread! -6

hello,
I opened a song using the system() , I want the song to run and also the program to continue executing its next instruction and not the program waiting till the song ends....
How will I do this ?

@artemisfowl12: you need to start your own thread. To answer your question, create another thread and play the song from there. If you are running MS-Windows you could call CreateProcess() instead of system(), but CreateProcess() is a little more complicated to call. Fortunately, most of the parameters can be 0 or NULL.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.