PDA

View Full Version : How can I delete program using QProcess?



remnant24c@nate.com
1st September 2009, 11:28
Hello guys

I'd like to delete program using QProcess.

My code "pp.exe"
//////////////////////////
QProcess *pro = new QProcess(0); //

connect( pro, SIGNAL(started()), this, SLOT(slotStart()) ); // 연결해서
...
void slotStart() { close(); }
...
pro->start("tt.exe");

/////////////////////////////////

so, i made "tt.exe" for deleting pp.exe file.

you know this can not use it because of instance.

then how should i solve it?


thanks for watching.

.

Boron
1st September 2009, 11:41
I had a similar problem some days ago (http://www.qtcentre.org/forum/f-qt-programming-2/t-sending-signal-to-other-process-23571.html).
I wanted to write an update routine for an application. A second executable should do the job.
The "update application" signals the real application via a flag in a QSharedMemory that it has to exit. Then the original exe can be deleted an be replaced by the newer exe.

The update exe is called via QProcess::startDetached() so that it is really a completely independent process.
When the "Start Update" button is clicked in the update exe it sets the falg to true.
After starting the update exe the real application waits for the flag in the shared memory to become "true" then it simply calls qApp->quit().
The update exe can now call QFile::remove(...) to delete the original exe and QFile::copy(...) to get the newer exe from our intranet.

faldzip
1st September 2009, 12:23
another way for updater is to change the architecture of your app: Make almost every part of your app a plugin, and let the .exe just load these plugins. Than the exe would not need any updates, and it can check for plugin updates before loading them so there would no problem with deleting/replacing them.