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

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,
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.

Edited 4 Years Ago by Ancient Dragon

This article has been dead for over six months. Start a new discussion instead.