【发布时间】:2017-10-02 22:03:14
【问题描述】:
我一直在尝试使用ShellExecute 和ShellExecuteEx 执行cmd.exe /c /v:on。但是,这两种方法似乎都只接受一个参数,因为当它遇到/v:on时,在Windows 7下会显示一个The filename, directory name, or volume label syntax is incorrect.。
这是我尝试过但目前正在搞乱的代码(没有运气):
#include <windows.h>
int main()
{
SHELLEXECUTEINFO info = {0};
info.cbSize = sizeof(SHELLEXECUTEINFO);
info.fMask = SEE_MASK_NOCLOSEPROCESS;
info.hwnd = NULL;
info.lpVerb = NULL;
info.lpFile = "cmd.exe";
info.lpParameters = "/c /v:on SET example=stackoverflow & ECHO '!example! & pause'";
info.lpDirectory = NULL;
info.nShow = SW_SHOW;
info.hInstApp = NULL;
ShellExecuteEx(&info);
// wait for process to terminate
// WaitForSingleObject(info.hProcess, INFINITE);
return 0;
}
【问题讨论】:
标签: c++ cmd parameters shellexecute shellexecuteex