问题
I'm trying to write a small program that just runs two executables. Currently it only runs the first one for some reason:
#include <windows.h>
#include <iostream>
using namespace std;
main(){
cout << "Running Borderless Window..." << endl;
system("BorderlessWindowed.exe");
cout << "Running Diablo II MultiRes..." << endl;
system("D2MultiResGame.exe.lnk");
}
It's just a small program to run Diablo II + a BorderlessWindow program.
回答1:
this will do the task
#include <windows.h>
#include <iostream>
using namespace std;
main(){
cout << "Running Borderless Window... and Diablo II MultiRes" << endl;
system("cmd /c start BorderlessWindowed.exe&&D2MultiResGame.exe.lnk");
// this is what i have tried
// system("cmd /c start notepad.exe&&mspaint.exe");
// which starts notepad and mspaint one after another
}
回答2:
Alright since system()
requires that the first process be done with before it launched the second I just created a batch file that starts both, and had the .exe launch the batch file.
来源:https://stackoverflow.com/questions/11464640/run-two-executables-with-system