我一直在尝试cmd.exe /c /v:on
使用ShellExecute
and来执行ShellExecuteEx
。但是,这两种方法似乎都只接受一个参数,因为当它遇到 时/v:on
,The filename, directory name, or volume label syntax is incorrect.
在 Windows 7 下会显示 a。
这是我尝试过的代码,目前正在搞乱(没有运气):
#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;
}