Page 1 of 1

wxExecute, detach process

Posted: Mon Oct 13, 2014 4:33 pm
by Leshka
Hello, Everyone!
I'm new user of wxWidgets and I trying to include WinSparkle (https://github.com/vslavik/winsparkle) library into my Qt application for autoupdating it.
Tte library has this code:

Code: Select all

if ( !wxLaunchDefaultApplication(m_updateFile) )                       //run installator, *.exe file
    {
        wxLogError(_("Failed to launch the installer."));
        wxLog::FlushActive();
    }
    else
    {
        Close();
        ApplicationController::RequestShutdown();                       //close parent application
    }
When parent application closed, installer process also closed. In Windows Task Manager in groups view installation process runs under parent process. I think installator must run separately from parent process.
I also trying to run installer with wxExecute() but it runs under parent process too.

In my Qt application I run process detached from parent using:

Code: Select all

(new QProcess(this->parent()))->start("calc.exe");
Sorry for my bad english:)

Re: wxExecute, detach process

Posted: Wed Oct 15, 2014 1:39 am
by Manolo
I understand that you have a Qt app and that you are re-coding in wxWidgets. Right?
I don't know WinSparkle, so I can't tell if you use it in your app1 or in another app2 you launch from app1.

wxLaunchDefaultApplication(myFile) is normally used when the OS knows the app needed to open myFile. In example, "myFile.txt" may be opened with Microsoft Notepad.

To run another executable file, you may use wxExecute(myExeFile) to launch it from app1. If you want app1 to wait (in a disabled stage) for myExeFile, use the flag wxEXEC_SYNC. If you launch the proccess asynchronously, still you can know when myExeFile is closed by using the 'callback' flag and handling callback->OnTerminate().
http://docs.wxwidgets.org/trunk/group__ ... 1b73399b33

In an app of mine, I do see two icons in the task bar, one for app1 an another one for myExeFile. What do you see if you compile and run yourwxdir\samples\exec?

Re: wxExecute, detach process

Posted: Sat Oct 18, 2014 7:27 am
by eranif
Have you tried running your installer with wxExecute?

This works (i.e. closing parent app will not terminate your calc program):

Code: Select all

::wxExecute("cmd /c calc", wxEXEC_ASYNC | wxEXEC_MAKE_GROUP_LEADER | wxEXEC_HIDE_CONSOLE);
Eran