Archey
Archey

Reputation: 1342

Run two executables with system()

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.

Upvotes: 2

Views: 1859

Answers (2)

Archey
Archey

Reputation: 1342

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.

Upvotes: 1

sunil
sunil

Reputation: 6614

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
}

Upvotes: 3

Related Questions