Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Update and Restart Exe
#1
Is there a way that a locally-running QM-generated exe can check some external condition (eg. whether there is a newer version on a network server) and then if so, pull down the new version and close the version that did the actual check and then start the new version.

Right now, I have this split between two exe's. One (Startup.exe) is in the startup folder. It checks, if new Main.exe version on the server, if not, launch local Main.exe. If new Main.exe version available, Startup.exe pulls down new Main.exe version, then launches "new" Main.exe local version.

Is there a way this can be done by only one installed exe? Once, this Main.exe

The only way I can think of:

1) Main.exe - at launch, pulls down a checking.exe and launches it. The checking exe then checks if Main.exe is up to date, if not, kills it and pulls/down and launches the new one.

I guess this is still two exe's but only requires install of one.

Any thoughts on most elegant way of handling this?

S
#2
One of possible ways. Don't need to create 2 files.

Function test_update_exe
Code:
Copy      Help
;Add this code at the beginning of your exe code.
;To understan this code, begin reading from the 'if need to update' line.

str exe1(ExeFullPath) exe2
if matchw(exe1 "*_new.exe") ;;updating
,1
,cop- exe1 exe2.fromn(exe1 exe1.len-8 ".exe" -1) ;;copy *_new.exe to *.exe
,run exe2 ;;run *.exe
,ret

exe2.fromn(exe1 exe1.len-4 "_new.exe" -1)
if FileExists(exe2)
,del- exe2; err
else if 'Y'=mes("Update exe?" "" "YN") ;;if need to update  (THE UPDATING PROCESS STARTS HERE)
,cop- exe1 exe2 ;;get new version. Cannot replace self. Save as *_new.exe.
,run exe2 ;;run *_new.exe, let it replace and run *.exe
,ret

err+ mes- exe1 "Failed to update" "!"
;____________________________________________

mes "Running." "" "i" ;;remove this
;...

Cannot update if in Program Files if running not as admin. Unless when installing you set your exe folder security to not require admin to write files.
#3
pure genius and elegant too!
Thanks!!!
S


Forum Jump:


Users browsing this thread: 1 Guest(s)