5 Replies - 3324 Views - Last Post: 26 September 2007 - 04:19 PM

#1 aj32   User is offline

  • D.I.C Addict
  • member icon

Reputation: 31
  • View blog
  • Posts: 577
  • Joined: 30-August 07

running a program in Dev-C++

Post icon  Posted 26 September 2007 - 02:47 PM

I need a way to run a program in Dev-C++, I cannot use
system("program.exe")
because it is for other compters.
I know how to do it in Visual C++. (I used:
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
	   Process^ myprocess = gcnew Process();
	   myprocess->StartInfo->FileName = "c:\\WINDOWS\\Notepad.exe";
	   myprocess->Start();
}
)
Now I need a way to do it in Dev-C++, I don't really know where to start with this :(, so I don't really have any code to show except what I used in Visual Studio .
Thank You

Is This A Good Question/Topic? 0
  • +

Replies To: running a program in Dev-C++

#2 jjhaag   User is offline

  • me editor am smartastic
  • member icon

Reputation: 48
  • View blog
  • Posts: 1,789
  • Joined: 18-September 07

Re: running a program in Dev-C++

Posted 26 September 2007 - 03:07 PM

View Postaj32, on 26 Sep, 2007 - 02:47 PM, said:

I need a way to run a program in Dev-C++, I cannot use
system("program.exe")
because it is for other compters.
I know how to do it in Visual C++. (I used:
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
	   Process^ myprocess = gcnew Process();
	   myprocess->StartInfo->FileName = "c:\\WINDOWS\\Notepad.exe";
	   myprocess->Start();
}
)
Now I need a way to do it in Dev-C++, I don't really know where to start with this :(, so I don't really have any code to show except what I used in Visual Studio .
Thank You


sorry, i was having a little trouble understanding this. are you saying that you can't use the system() command because you are compiling this program for use on other computers, and don't know where the program is located? because the system("program.exe") command will work - the behavior and return value can be OS dependent, but it will still pass the command to the OS.

try this:
#include <iostream>
int main() {
	system("C:\\windows\\notepad.exe");
	return 0;
}


and see what happens

-jjh
Was This Post Helpful? 0
  • +
  • -

#3 aj32   User is offline

  • D.I.C Addict
  • member icon

Reputation: 31
  • View blog
  • Posts: 577
  • Joined: 30-August 07

Re: running a program in Dev-C++

Posted 26 September 2007 - 03:31 PM

What I am trying to do is put this program on a CD, the main program that I am writting is in the same directory as the other program, if I use something like "system("H:\program.exe");" it would not work on most other computers because H can be any other drive letter (D, E, ect). I also tried to use
system("program.exe");
but this just froze my computer by running the program an infinate number of times, plus the program never showed up.
Thanks
Was This Post Helpful? 0
  • +
  • -

#4 jjhaag   User is offline

  • me editor am smartastic
  • member icon

Reputation: 48
  • View blog
  • Posts: 1,789
  • Joined: 18-September 07

Re: running a program in Dev-C++

Posted 26 September 2007 - 03:53 PM

View Postaj32, on 26 Sep, 2007 - 03:31 PM, said:

What I am trying to do is put this program on a CD, the main program that I am writting is in the same directory as the other program, if I use something like "system("H:\program.exe");" it would not work on most other computers because H can be any other drive letter (D, E, ect). I also tried to use
system("program.exe");
but this just froze my computer by running the program an infinate number of times, plus the program never showed up.
Thanks



what do you mean by "just froze my computer by running the program an infinate number of times"? which program was run repeatedly?

please post the source code pertaining to launching the external app so we can see where things might be going wrong.

if you're running it from the same directory, system("program.exe") should work. is the program to be launched something you wrote, and if so, are you sure it's working properly?

try the absolute simplest code you need to test what you want to do:
#include <iostream>
int main(int argc, char* argv) {
	system("program.exe");
	return EXIT_SUCCESS;
}


try that, making sure "program.exe" is in the same directory as your executable, and see what happens. if it doesn't work, describe very precisely what does occur so we can help find the bug.

-jjh
Was This Post Helpful? 0
  • +
  • -

#5 aj32   User is offline

  • D.I.C Addict
  • member icon

Reputation: 31
  • View blog
  • Posts: 577
  • Joined: 30-August 07

Re: running a program in Dev-C++

Posted 26 September 2007 - 04:06 PM

That works, I added "return 0;" right after the "system("program.exe");" and it only started one program(what was happening is that the program was started over and over agian, in task manager the whole this was filled up with "program.exe")
Thank You for putting up with my stupid moment :rolleyes: :D !!!!
Was This Post Helpful? 0
  • +
  • -

#6 jjhaag   User is offline

  • me editor am smartastic
  • member icon

Reputation: 48
  • View blog
  • Posts: 1,789
  • Joined: 18-September 07

Re: running a program in Dev-C++

Posted 26 September 2007 - 04:19 PM

View Postaj32, on 26 Sep, 2007 - 04:06 PM, said:

That works, I added "return 0;" right after the "system("program.exe");" and it only started one program(what was happening is that the program was started over and over agian, in task manager the whole this was filled up with "program.exe")
Thank You for putting up with my stupid moment :rolleyes: :D !!!!



we've all had those moments :) . glad that you got it up and running.

-jjh
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1