I have written a Qt application that downloads and then executes an MSI file. The execution is done via
Exception thrown: read access violation
QProcess *process = new QProcess(this);
QString program = "file.msi";
QString folder = "C:\\Users\\user\\Downloads\\";
process->start(program, QStringList() << folder);
The problem comes from the fact that an MSI file is an installation file thus it requires administrator privileges.
There are two options:
QDesktopServices::openUrl(QUrl("file:///<path to your MSI file>"), QUrl::TolerantMode));(as suggested here) instead of using
QProcess::startDetached("runas /user:<localmachinename>\user msiFileName");where you replace the respective strings with your own (for that you should check the documentation of
runassince this has nothing to do with Qt but with the command line arguments of
In addition you can run your Qt application with administrator privileges. In order to save the user the rouble of doing it manually you can use this to tell Windows what the default execution of your Qt application is supposed to be. This is something I would advise against because your application may introduce a security breach in the system that you can be held liable for.