#include <iostream>
#include <windows.h>
#include <ShellAPI.h>
int main()
{
SHELLEXECUTEINFO se;
memset(&se, 0, sizeof(SHELLEXECUTEINFO));
se.cbSize = sizeof(SHELLEXECUTEINFO);
se.lpVerb = L"runas";
se.lpFile = L"cmd.exe"; //要打開的進程路徑
se.lpParameters = L"Administrator" //管理員權限
se.nShow = SW_HIDE;//打開的進程不顯示界面
se.fMask = 0;//不要進程句柄
if(ShellExecuteEx(&se))
{
std::cout << "successfully"<<endl;
}
else
{
std::cout << "fail"<<endl;
}
return 0;
}