FileCopyDir to replace the current active AHK-exe?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Peter2
Posts: 325
Joined: 21 Sep 2014, 14:38
Location: CH

FileCopyDir to replace the current active AHK-exe?

29 Jun 2017, 02:47

I made a simple "Updater" with my compiled AHK-script:
  • Download some files to download-folder
  • Copy the files with FileCopyDir from download-folder to target-folder
It works fine, but now I'm at the point: How to update the updater?
In the current situation it would be..

Code: Select all

c:\project\myupdater.exe starts the command to copy c:\download\myupdater.exe to c:\project\myupdater.exe while it is active
I'm afraid that this will cause problems.

I'm sure it can be solved (somehow) - but is there a "standard, approved command or function" to do it?

Thanks
Peter (AHK Beginner) / Win 10 x64, AHK Version v1.1.33
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: FileCopyDir to replace the current active AHK-exe?

29 Jun 2017, 03:43

You should have a look as well if IExpress is available with your OS: Start > Run > IExpress

https://en.wikipedia.org/wiki/IExpress
https://technet.microsoft.com/de-de/lib ... 96369.aspx

PS. You can save/archive the configuration of an already created installation procedure/package within an SED-file (eg as an template, because SED is just another name for an INI file). That way you could automate the creation of your installation packages via IExpress using an AHK script.
IExpress.exe uses SED files, which are really just text files that describe the parameters used when building the package. To build a self-extracting installer on the command line, you just run IEXPRESS with the SED file as an argument:

iexpress /N Your_SED_Script.sed

The /N is to invoke unattended package building. Without it, the IExpress GUI wizard will simply pop up.
You can generate SED files by going through the IExpress wizard, or you can try to generate them automatically with some of your own code.
Let's look at the structure of an SED script to get you started. [...]
Spoiler
https://ss64.com/nt/iexpress-sed.html

:)
Last edited by BoBo on 29 Jun 2017, 04:30, edited 4 times in total.
lexikos
Posts: 9592
Joined: 30 Sep 2013, 04:07
Contact:

Re: FileCopyDir to replace the current active AHK-exe?

29 Jun 2017, 04:07

You can update the exe by first renaming or moving the original file with FileMove, and then copying or moving the new file to the original location. You cannot delete or overwrite an exe while it is running, but you can move (or rename) it if the source and destination are on the same physical volume.

Alternatively, you can use an external script (compiled script, batch file, vbs, etc.). For instance, have your exe launch some other script which terminates your exe and then replaces it.
Peter2
Posts: 325
Joined: 21 Sep 2014, 14:38
Location: CH

Re: FileCopyDir to replace the current active AHK-exe?

29 Jun 2017, 05:29

Thanks to both - fine solutions!
Peter (AHK Beginner) / Win 10 x64, AHK Version v1.1.33

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], jaka1 and 183 guests