Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Windows - have program replace itself

by JediWizard (Deacon)
on Sep 27, 2004 at 15:57 UTC ( [id://394216]=note: print w/replies, xml ) Need Help??


in reply to Windows - have program replace itself

Well if you are copying the new version over the old version, this should work:

exec($0);
May the Force be with you

Replies are listed 'Best First'.
Re^2: Windows - have program replace itself
by sgifford (Prior) on Sep 27, 2004 at 16:31 UTC

    IIRC, the problem is that Windows won't let you overwrite or delete a running program; that's why upgrades of running programs often require a reboot.

    Assuming exec works properly on Windows, one possible workaround would be to launch a second script which would download the first script, then re-execute it:

    # script 1 sub upgrade { exec('upgrade',$0,@ARGV) or die "exec failed! $!\n"; } # upgrade script download_new_version($ARGV[0]); exec(@ARGV) or die "exec failed! $!\n";
Re^2: Windows - have program replace itself
by jdtoronto (Prior) on Sep 27, 2004 at 16:20 UTC
    gee, all of 9 characters, bit excessive?

    LOL

    But serenely elegant if I may say so, thank you very much JediWizard I will give it a try :)

    jdtoronto

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://394216]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-25 20:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found