简体   繁体   中英

How set .bat file to C++

Can any one help ,i have create bat file now i want convert to C++

In my .bat file i need to create another file call name.bat, so right now i want use C++ to execute all this command.

Here my Sample:

set /p CID=Curr_ID= 

set /p CIP=Curr_IP= 

set /p CIS=Curr_SUBNET= 

echo Curr_POrt must convert HEx to Dec

set /p CIPR=Curr_PORT= 

set /p NID=New_ID= 

echo cd\ >> if.bat

echo cls >> if.bat

echo if exist del.bat goto :label1 >> if.bat

echo :label1 >> if.bat

echo cd\ >> if.bat

echo c: >> if.bat

echo cls >> if.bat

echo @echo off

echo echo Setup Done !!! >> if.bat

echo pause >> if.bat

echo del del.bat >> if.bat

echo del name.bat >> if.bat

echo del if.bat >> if.bat

echo exit >> if.bat

echo del name.bat >> del.bat

echo cd rdsconfig >> name.bat

echo rdsconfig.exe /CURR_ID=%CID% /CURR_IP=%CIP% /CURR_SUBNET=%CIS% /CURR_PORT=%CIPR% /NEW_ID=%NID% /NEW_IP=192.168.2.%NID% /NEW_SUBNET=255.255.255.0 /NEW_PORT=33536 >> name.bat

START name.BAT

I don't think you can efficiently auto-convert from batch to C++, but you could just run each of the commands in the batch file sequentially with system(). Here's an example:

#include <cstdlib>

int main(int argc, char **argv) {
    system("cls");
    return 0;
}

That would clear the screen. I hope this helps.

我没有办法将BATCH自动转换为C ++,但是如果您只想要一个EXE,那么有很多应用程序可以为您执行此操作,例如BatToEXE

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM