how to start an .exe file using my c++ code?

how do i open an external program and close it from using c++ ?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <windows.h>
#include <cstdio>
#include <fstream>
#include <string>
using namespace std;

int main(int argc, char** argv) {
	std::cout << "starting my program!...\n";
	
	system("C:\\abc\\xyz.bat"); //this xyz.bat starts xyz.exe with some instructions. 
	//i want to start this program in another console. 
	//but it starts in same consol and remain open. and below lines never exicuted  :(
	
	Sleep(3000); //it takes minimum 2.5 sec to load
	
	std::cout << "started\n";
	
	Sleep(2000);
	
	return 0;
}
Last edited on
thanks solved by
1
2
system ("START  C:\\abc\\xyz.bat");
// and rest of the code  
Last edited on
Topic archived. No new replies allowed.