main.cpp
1 #include <iostream> 2 #include <fstream> 3 #include <unistd.h> 4 #include <windows.h> 5 #include <string.h> 6 7 #define MAX_BUF 1024*1024 8 #define CFG_NAME "command.ini" 9 10 using namespace std; 11 12 int main() { 13 string path = _pgmptr; 14 path += "/.."; 15 chdir ( path.c_str() ); 16 char buf[MAX_BUF]; 17 ifstream in ( CFG_NAME ); 18 if ( !in.is_open() ) { 19 cout << "Can not open " << CFG_NAME << "." << endl; 20 Sleep ( 3000 ); 21 return 1; 22 } 23 if ( !in.eof() ) { 24 in.getline ( buf, MAX_BUF ); 25 } 26 in.close(); 27 system ( buf ); 28 return 0; 29 }
command.ini
1 where cmd > C:\testfile.txt