使用cmd启动程序

时间:2013-01-10 17:22:23

标签: c++ file cmd

我尝试制作一个打开其他程序的C ++程序(使用cmd)。代码:

int main(){
int i=0,t;
string progs[100];
fstream db("db.txt",ios::in);
while(getline(db,progs[i++])) {}


for(t=0;t<i-1;t++) {
    string open="start "+progs[t];
    system(open.c_str());
}

system("pause");
return 0;
}

程序位于桌面上,适用于所有文件。 问题是它无法打开名为KBot.exe的程序(它表示该程序不存在)。 例如,我在db.txt中写道:

patch.exe
KBot.exe
Shutdown + tasks.exe

所有3个都位于桌面上,但程序只打开第一个和最后一个。 是的,程序名称写得正确。导致它的原因是什么?

1 个答案:

答案 0 :(得分:2)

  • 您的循环错误:s/b (t=0;t<i;t++)
  • patch.exe并且关机可能在您的$PATHKBot不在。
相关问题