Windows script auto-update replacing current executable with exec?
Asked Answered
V

1

8

I'm trying to build a quick auto-updater in Perl Windows. I've noticed that when I call cpanp to install the update of the package it fails to install a new version of the script because the script is currently running. I'm calling cpanp with CORE::system() currently. If I called cpanp with exec() would that release the executable for replacement? Or, does Windows keep it tied up even though execution has been turned over entirely to cpanp?

Currently, my process flow looks something like this,

  1. Download META.yml from server
  2. Parse out the version of META.yml
  3. Compare against the current $VERSION
    • If the current version is lower, generate a version string using the data in META.yml
      1. Generate a URL to package using the host/path fo META.yml and the version/data information
      2. Inform user of update
      3. Spawn cpanp to run update with URL.
    • If the current version is the same
      1. Do nothing

Would system() behave differently than exec() on Win32 with regard to replacement of the executable? On Linux it works as designed.

Valdis answered 3/6, 2013 at 16:17 Comment(1)
Are you talking about the Perl Executable?Titustityus
T
1

I just tested it. exec works as it should on both Linux and Win32. See this page for portability info on Perl.

Titustityus answered 20/8, 2013 at 6:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.