Following this post, I intent to run this command in my Qt 5.12.6 application on Windows 10 with admin privileges:
powershell -Command "agent.exe -Verb runAs"
My agent.exe
is next to my Qt application executable, i.e. its parent directory would be QCoreApplication::applicationDirPath()
.
Inspired by another post, my C++/Qt code looks like:
m_agent = new QProcess(this);
QString agentName = "/agent.exe";
// "agent.exe" executable is next to application executable
QString agentPath = QCoreApplication::applicationDirPath() + agentName;
QStringList args = QStringList();
// I'm not sure how to compose `args`
args << "-Command"; // ?
args << agentPath; // ?
args << "-Verb"; // ?
args << "runAs"; // ?
m_agent->start("powershell ", args);
My current args
, composed above, is not starting the agent.exe
.
My questions is: how should I compose args
to be able to run my Windows PowerShell command with Qt?