PDA

View Full Version : Information From Detached Process



GTBuilder
16th February 2008, 21:35
I'm using a DOS command file to execute a series of actions, including sending text to the DOS screen, etc.

Example of code:


void Clone::selectDriveP()
{
if( driveOnoff)
{
twProcess.startDetached( "TW_install_P.bat");
driveOnoff = false;
}
}

I think I have to use startDetached in order to see the DOS screen. However, it seems that because I'm using startDetached, I cannot get signals from the detached process such as start(), finished( int , QProcess::ExitStatus), etc.

Is there something I'm missing?

marcel
16th February 2008, 21:47
When running batch files, you must use the command prompt:


%comspec% /k ""C:\path\to\your\batch\file.bat" x86


Execute the batch file like that and there will be no need to use start detached.

GTBuilder
17th February 2008, 01:10
Not sure how this helps me. Issue isn't how to launch cmd.exe and the batch file.

How do I get signals back to the parent widget about what the batch file is doing? That's why I wanted to use QProcess.

marcel
17th February 2008, 01:14
You said that you can't see the command line window and that is why you resorted to startDetached.

In order to see the command window and NOT use startDetached, you must execute the batch file as I have shown you.


How do I get signals back to the parent widget about what the batch file is doing? That's why I wanted to use QProcess.

cmd will exit as soon as the batch finishes executing. Therefore start() and finish() will have the correct meaning.

GTBuilder
17th February 2008, 20:52
I modified the code as follows:



void Clone::selectDriveP()
{
if( driveOnoff)
{
QStringList arg;
arg << "/k" << "tw_install_p.bat";
twProcess.start( "cmd.exe", arg);
driveOnoff = false;
}
}


Note that cmd.exe and tw_install_p.bat are in the parent directory.

I get a started() signal but no finished() signal. I don't see a dos window and cmd.exe is not seen in Task Manager.

Clearly I'm doing something stupid here. :confused:

codeslicer
17th February 2008, 23:43
Thanks in my thread builder :P

Try looking at this thread:
http://www.qtcentre.org/forum/f-qt-programming-2/t-problem-executing-process-11463.html

GTBuilder
18th February 2008, 15:49
I've been assuming that the issue is with starting a command file. However, when I try to run a generic Windows program using the same QProcess and examining the errorString, I get "Unknown Error" even though the Windows program runs normally. Presumably this is why I get a started() signal but no finished() signal.

Any suggestions about where I should be looking? :confused: