Issue with QProcess and rundll32
-
Hello!
I want to use the
QProcess
to remove some installed programs. The problem is withrundll32.exe
.For example, I want to uninstall this one:
C:\Windows\SysWOW64\RunDll32.EXE C:\Program Files\NVIDIA Corporation\Installer2\InstallerCore\NVI2.DLL,UninstallPackage CUDADevelopment_11.8
Code:
QProcess *appProcess = new QProcess(this); connect(appProcess, &QProcess::started, this, [this, appProcess]() { qDebug() << appProcess->errorString(); }); connect(appProcess, qOverload<int>(&QProcess::finished), this, [this, appProcess]() { qDebug() << "Error: " << appProcess->errorString(); appProcess->close(); appProcess->removeLater(); emit finished(); }); QStringList runDll32Path = item->text(column).split(".exe", QString::KeepEmptyParts, Qt::CaseInsensitive); QString appPath = runDll32Path.first().append(".exe"); QString appParameter = runDll32Path.last().simplified(); qDebug() << "appPath: " << appPath; QStringList appArgs = appParameter.split(".dll", QString::KeepEmptyParts, Qt::CaseInsensitive); QString arg1 = appArgs.first().append(".dll"); QString arg2 = appArgs.last(); appProcess->start(appPath, QStringList() << QString("\"%1\"%2").arg(arg1, arg2));
It reports:
appPath: "C:\\Windows\\SysWOW64\\RunDll32.exe" Args: "\"C:\\Program Files\\NVIDIA Corporation\\Installer2\\InstallerCore\\NVI2.dll\",UninstallPackage CUDADevelopment_11.8" "Unknown error" Error: "Unknown error"
But the process immediatly closes and does not display any dialog.
I have tried it withShellExecute
and it works well but it fails withQProcess
.
I want to use it withQProcess
to check if the process is still running or not. Any ideas? Thank you. -
@JonB
Hello!The quotes must be there for argument otherwise it will not start. Using
CMD
,ShellExecute
orRun
app it starts.Here is an example:
rundll32.exe "C:\\Program Files\\Synaptics\\SynTP\\SynISDLL.dll",standAloneUninstall
Here is the screenshot:
It fails with
QProcess
for some reason.@Cobra91151
If it were me I would probably try using void QProcess::setNativeArguments(const QString &arguments) now to be sure what I was passing. By-passing Qt's quoting of your argument(s). -
Hello!
I want to use the
QProcess
to remove some installed programs. The problem is withrundll32.exe
.For example, I want to uninstall this one:
C:\Windows\SysWOW64\RunDll32.EXE C:\Program Files\NVIDIA Corporation\Installer2\InstallerCore\NVI2.DLL,UninstallPackage CUDADevelopment_11.8
Code:
QProcess *appProcess = new QProcess(this); connect(appProcess, &QProcess::started, this, [this, appProcess]() { qDebug() << appProcess->errorString(); }); connect(appProcess, qOverload<int>(&QProcess::finished), this, [this, appProcess]() { qDebug() << "Error: " << appProcess->errorString(); appProcess->close(); appProcess->removeLater(); emit finished(); }); QStringList runDll32Path = item->text(column).split(".exe", QString::KeepEmptyParts, Qt::CaseInsensitive); QString appPath = runDll32Path.first().append(".exe"); QString appParameter = runDll32Path.last().simplified(); qDebug() << "appPath: " << appPath; QStringList appArgs = appParameter.split(".dll", QString::KeepEmptyParts, Qt::CaseInsensitive); QString arg1 = appArgs.first().append(".dll"); QString arg2 = appArgs.last(); appProcess->start(appPath, QStringList() << QString("\"%1\"%2").arg(arg1, arg2));
It reports:
appPath: "C:\\Windows\\SysWOW64\\RunDll32.exe" Args: "\"C:\\Program Files\\NVIDIA Corporation\\Installer2\\InstallerCore\\NVI2.dll\",UninstallPackage CUDADevelopment_11.8" "Unknown error" Error: "Unknown error"
But the process immediatly closes and does not display any dialog.
I have tried it withShellExecute
and it works well but it fails withQProcess
.
I want to use it withQProcess
to check if the process is still running or not. Any ideas? Thank you.@Cobra91151
I am not convinced about your quoting of the argument, and tbh I'm note sure exactly whatrundll32
will be requiring there. I would try removing the surrounding"
s you have put inQString("\"%1\"%2").arg(arg1, arg2)
.C:\Windows\SysWOW64\RunDll32.EXE C:\Program Files\NVIDIA Corporation\Installer2\InstallerCore\NVI2.DLL,UninstallPackage CUDADevelopment_11.8
Are you saying that if you type this in verbatim in a Command Prompt it would work exactly as shown?
-
@JonB
Hello!The quotes must be there for argument otherwise it will not start. Using
CMD
,ShellExecute
orRun
app it starts.Here is an example:
rundll32.exe "C:\\Program Files\\Synaptics\\SynTP\\SynISDLL.dll",standAloneUninstall
Here is the screenshot:
It fails with
QProcess
for some reason. -
@JonB
Hello!The quotes must be there for argument otherwise it will not start. Using
CMD
,ShellExecute
orRun
app it starts.Here is an example:
rundll32.exe "C:\\Program Files\\Synaptics\\SynTP\\SynISDLL.dll",standAloneUninstall
Here is the screenshot:
It fails with
QProcess
for some reason.@Cobra91151
If it were me I would probably try using void QProcess::setNativeArguments(const QString &arguments) now to be sure what I was passing. By-passing Qt's quoting of your argument(s). -
@Cobra91151
If it were me I would probably try using void QProcess::setNativeArguments(const QString &arguments) now to be sure what I was passing. By-passing Qt's quoting of your argument(s).Ok. I will try it and reply later. Thank you.
-
@Cobra91151
If it were me I would probably try using void QProcess::setNativeArguments(const QString &arguments) now to be sure what I was passing. By-passing Qt's quoting of your argument(s).Yes, it works well. The issue is resolved. Thank you for your help.