Solved exe file replace using QProcess
-
@4j1th said:
I am trying to update my soft. itself in windows, I can't replace a running exe itself with in so I try to do it by using QProcess.
You can't, the OS will lock the file and will not allow you to modify it. It doesn't matter if you use
QProcess
orcmd
, orexplorer
, it will not work. -
@mrjj no luck it can't delete any file
-
@kshegunov so you're suggesting me to write another programme to run update
But this idea works on linux.
-
@4j1th
Hi
just tested in win 7.
it wont allow to delete running exe.Linux will, i know. but Windows wont allow.
-
@mrjj can you delete any other file, I can't do it either
-
@4j1th
hiQProcess process; process.start("cmd", QStringList() <<"/C" << "del" << "e:/test.txt " );
this delete the file i put on e:\
-
you're right, can't replace running exe, so I think the best way to update is write an another app for updation right?
-
@4j1th
Well even another program cannot override the exe, so the updater must
close the running version. -
@mrjj Thank you for your help, this is the second time you help me like a guru
Thank you
-
@4j1th
You are most welcome :)
The exe you are trying to update. is it your own program? -
@mrjj yes
-
@4j1th
Ok. that makes it easier to get it to close. :)
Will user check for update from inside the program or how will that happen?
(if i may ask) -
@mrjj When the app starts it checks for update if available-> ask for update permission(user) -> invoke the updater using QProcess -> as you said close the app -> download and replace the exe
-
@mrjj Qt installer framework can replace a running exe and dll I don't know how!
-
@4j1th said:
well on windows its not so hard using windows API. -
There is a link to an article that talks about this problem and possible solutions. http://www.catch22.net/tuts/self-deleting-executables on Windows.
I, personally, would try to keep this sane. A separate updating utility that closes the original program and replaces or removes whatever should be replaced or removed is probably the safest thing to do.
-
I, personally, would try to keep this sane. A separate updating utility that closes the original program and replaces or removes whatever should be replaced or removed is probably the safest thing to do.
I completely agree!
-
Hi,
One possibility would be to use the Qt Installer Framework that, AFAIK, has an updating functionality
-
;)
Do not worry
he is not planning on overwriting the exe from WITHIN the exe :)
Even @Rondogs link is pretty interesting,
it does indeed smell of a complex way of shooting your foot off :) -
@SGaist
tried qt installer framework but I don't think it can help the auto updating, launch a topic on this please see this linkhttps://forum.qt.io/topic/61811/qt-installer-framework-auto-update