wxExecute, detach process

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Leshka
In need of some credit
In need of some credit
Posts: 1
Joined: Mon Oct 13, 2014 4:16 pm

wxExecute, detach process

Post 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:)
Manolo
Can't get richer than this
Can't get richer than this
Posts: 827
Joined: Mon Apr 30, 2012 11:07 pm

Re: wxExecute, detach process

Post 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?
eranif
Moderator
Moderator
Posts: 610
Joined: Tue Nov 29, 2005 7:10 pm
Location: Israel

Re: wxExecute, detach process

Post 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
IDE: CodeLite + wxCrafter
OS: All
https://wxcrafter.codelite.org
https://codelite.org
Post Reply