我試圖在C++中使用win32 api執行以下bat文件。以下是執行代碼。ShellExecute()不能與.bat文件一起工作
//#include "Shellapi.h"
#include "Windows.h"
int _tmain(int argc, _TCHAR* argv[])
{
ShellExecute(GetDesktopWindow(), "sa.bat","", NULL, NULL, SW_SHOWNORMAL);
DWORD LastError = GetLastError();
return 0;
}
但它不工作。
以下是內容 「sa.bat」
C:\ WINDOWS \ SYSTEM32 \ WUSA /卸載/ KB:2718695 /寧靜/ forcerestart
但最後一個錯誤返回1155
比較你的論點:http://msdn.microsoft。com/en-ca/library/windows/desktop/bb762153(v = vs.85).aspx – chris
你弄錯了參數,「sa.bat」應該作爲** third **參數傳遞。 –
@HansPassant沒有它的不是:-(我的東西所以一些錯誤的批處理command.Did你的東西所以??請問我的新問題 – Aryan