Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Issue with QProcess and rundll32
Forum Updated to NodeBB v4.3 + New Features

Issue with QProcess and rundll32

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 429 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Cobra91151C Offline
    Cobra91151C Offline
    Cobra91151
    wrote on last edited by Cobra91151
    #1

    Hello!

    I want to use the QProcess to remove some installed programs. The problem is with rundll32.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 with ShellExecute and it works well but it fails with QProcess.
    I want to use it with QProcess to check if the process is still running or not. Any ideas? Thank you.

    JonBJ 1 Reply Last reply
    0
    • Cobra91151C Cobra91151

      @JonB
      Hello!

      The quotes must be there for argument otherwise it will not start. Using CMD, ShellExecute or Run app it starts.

      Here is an example:
      rundll32.exe "C:\\Program Files\\Synaptics\\SynTP\\SynISDLL.dll",standAloneUninstall

      Here is the screenshot:

      Rundll32_cmd.gif

      It fails with QProcess for some reason.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #4

      @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).

      Cobra91151C 2 Replies Last reply
      1
      • Cobra91151C Cobra91151

        Hello!

        I want to use the QProcess to remove some installed programs. The problem is with rundll32.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 with ShellExecute and it works well but it fails with QProcess.
        I want to use it with QProcess to check if the process is still running or not. Any ideas? Thank you.

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #2

        @Cobra91151
        I am not convinced about your quoting of the argument, and tbh I'm note sure exactly what rundll32 will be requiring there. I would try removing the surrounding "s you have put in QString("\"%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?

        1 Reply Last reply
        0
        • Cobra91151C Offline
          Cobra91151C Offline
          Cobra91151
          wrote on last edited by Cobra91151
          #3

          @JonB
          Hello!

          The quotes must be there for argument otherwise it will not start. Using CMD, ShellExecute or Run app it starts.

          Here is an example:
          rundll32.exe "C:\\Program Files\\Synaptics\\SynTP\\SynISDLL.dll",standAloneUninstall

          Here is the screenshot:

          Rundll32_cmd.gif

          It fails with QProcess for some reason.

          JonBJ 1 Reply Last reply
          0
          • Cobra91151C Cobra91151

            @JonB
            Hello!

            The quotes must be there for argument otherwise it will not start. Using CMD, ShellExecute or Run app it starts.

            Here is an example:
            rundll32.exe "C:\\Program Files\\Synaptics\\SynTP\\SynISDLL.dll",standAloneUninstall

            Here is the screenshot:

            Rundll32_cmd.gif

            It fails with QProcess for some reason.

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #4

            @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).

            Cobra91151C 2 Replies Last reply
            1
            • JonBJ JonB

              @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).

              Cobra91151C Offline
              Cobra91151C Offline
              Cobra91151
              wrote on last edited by
              #5

              @JonB

              Ok. I will try it and reply later. Thank you.

              1 Reply Last reply
              0
              • JonBJ JonB

                @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).

                Cobra91151C Offline
                Cobra91151C Offline
                Cobra91151
                wrote on last edited by
                #6

                @JonB

                Yes, it works well. The issue is resolved. Thank you for your help.

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved