我有两个应用程序--A和B. B有' requireAdminstrator '清单,我想从标准令牌中的应用程序A调用它。 UAC是'从不通知'。
真的有可能吗?
我已经尝试CreateProcess
和CreateProcessWithLogonW
并且都返回FALSE,GetLastError显示 740 (请求的操作需要提升。)
答案 0 :(得分:0)
以下代码可用于此:
SHELLEXECUTEINFO shExecInfo;
shExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
shExecInfo.fMask = NULL;
shExecInfo.hwnd = NULL;
shExecInfo.lpVerb = L”runas“;
shExecInfo.lpFile = L”notepad.exe”;
shExecInfo.lpParameters = NULL;
shExecInfo.lpDirectory = NULL;
shExecInfo.nShow = SW_MAXIMIZE;
shExecInfo.hInstApp = NULL;
ShellExecuteEx(&shExecInfo);
参考:
https://blogs.msdn.microsoft.com/vistacompatteam/2006/09/25/elevate-through-shellexecute/