Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Update and Restart Exe
#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.


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)