2012-07-13 74 views
2

我想寫一個只運行兩個可執行文件的小程序。目前,它只能運行一些原因,第一個:運行兩個可執行文件與系統()

#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"); 
} 

這只是一個小程序運行暗黑破壞神II +一個BorderlessWindow程序。

+0

它應該讀取'int main()'... – 2012-07-13 05:30:14

+1

'系統'不會(通常)返回,直到您指示它執行的任何程序退出。你可以切換到'spawnvp'(或它的一個表兄弟),或使用'start'來執行命令並立即返回(以及其他可能性)。 – 2012-07-13 05:31:08

回答

3

這會做的任務,因爲system()

#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 
} 
+0

謝謝:)它第一次運行良好,但第二它仍然在做我的代碼。只運行BorderlessWindowed.exe並不打開第二個。 – Archey 2012-07-13 05:58:57

+0

@Archey好的...嘗試更新的代碼。從Windows開始添加併發應用程序。現在可以同時啓動這兩個應用程序,而不用等待其他任務完成 – sunil 2012-07-13 07:30:28

+0

@Archey是否能夠測試這個? – sunil 2012-07-15 17:02:04

1

好吧要求第一個過程與之前它推出我剛剛創建這會啓動一個批處理文件,第二個完成,並有.exe文件啓動一批文件。

相關問題