bat向html传参,C++调用bat并实现传值

1.设置环境变量,这一类为路径

C++

void bat(const string& sDirC, const string& sDirD)

{

char Ddir[256];

Ddir[0] = 0;

sprintf_s(Ddir, "DDIR=%s%s", (char*)sDirD.data(), "\\");

_putenv(Ddir); //将地址设置到当前环境中

char Cdir[256];

Cdir[0] = 0;

sprintf_s(Cdir, "CDIR=%s%s", (char*)sDirC.data(), "\\");

_putenv(Cdir);

system("..\\..\\Bin\\x64\\copy.bat" );     //调用bat 推荐下面那种

/*if (WinExec("..\\..\\Bin\\x64\\copy.bat", SW_HIDE) < 32)

{

AfxMessageBox(L" 无法调用 ..\\..\\Bin\\x64\\copy.bat", NULL, MB_OK);

return false;

}*/

}

Bat

set tmpDir=%DDIR%

md %tmpDir%

if not exist %tmpDir% (

set tmpDir=%CDIR%

md %tmpDir%

)

2.直接传值

bat默认只能获取到1-9个参数,分别用%1 %2 ... %9引用,如果传给bat的参数大于9个,就要用shift。

void bat(const CString& csVersion)

{

char packCmd[256];

sprintf_s(packCmd, "%s%s","..\\..\\Bin\\x64\\pack.bat ", T2A(csVersion));

//system(packCmd);

if (WinExec(packCmd, SW_HIDE) < 32)

{

AfxMessageBox(L"..\\..\\Bin\\x64\\pack.bat ", NULL, MB_OK);

return false;

}

}

set abc=XXX%1

原文:https://www.cnblogs.com/hao11/p/12027337.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值