Important: Please read the Qt Code of Conduct -

Installing softwares using installers in Qt Application

  • Hii all..

    I want to install some softwares from their .exe installers from the Qt application. For this i simply used this commands..

    First Qprocess Header file is included and the following line is added after the main windows show line.

    @process.start("cmd", QStringList() << "C:\CodeBlocks_setup.exe");@

    But nothing is happening.. It is saying that an instance of CMD is running but no Installation wizard shows up..

    But, if i enter the "C:\CodeBlocks_setup.exe" inside cmd prompt, the installation wizard shows up...

    What is the problem with the Qt API above ?

  • Even as simple as
    @process.start("cmd", QStringList() << "help");@
    is not showing anything..

    But, this should output the "help" command output in cmd.

  • Why not run the installer directly?
    @QProcess process;
    process.start("C:\CodeBlocks_setup.exe", QStringList());@

    Anyway, if you want to use the command interpreter, then try:
    @QProcess process;
    QStringList args;
    args << "/c";
    args << "C:\CodeBlocks_setup.exe";
    process.start("cmd.exe", args);@


    See also:
    [quote]C:\Users\MuldeR>cmd /?
    Starts a new instance of the Windows command interpreter

    CMD [/A | /U] [/Q] [/D] [/E:ON | /E:OFF] [/F:ON | /F:OFF] [/V:ON | /V:OFF]
    [[/S] [/C | /K] string]

    /C Carries out the command specified by string and then terminates[/quote]

  • BTW: You may which to use "%COMSPEC%": instead of hardcoding the path to the command interpreter ("cmd.exe"):

    @const wchar_t envComSpec = _wgetenv(L"ComSpec");
    const QString comSpec = QString::fromUtf16(reinterpret_cast<const ushort
    >(envComSpec ? envComSpec : L"cmd.exe"));
    process.start(comSpec, args);@

  • Thanks MuldeR...

    All of the above methods worked.. :D
    I had already tried first method, but i guess i did somewhere wrong..

    I never heard of ComSpec... Thankyou again...

Log in to reply