Run two executables with system()

痞子三分冷 提交于 2019-12-12 18:57:19

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!