'''Starpacks: Why and how to copy your own executable and launching the copied instance''' The Problem: Executables, like starpacks, are often called from single network shares from many users in parallel. So the chance is good, that at least one user has an instance of that specific program running all the time. Now the administration wants to update that program. But this is not possible (at least) under MS-Windows, because each executable on disk, which has running instances active, is locked (such lock is invisible via ''net files''). The Solution: Each user has to launch his own private copy of the program. But this must not lead to an distribution overhead: the program is still distributed only once to the network share, then each instance copies itself to a temporary position, runs from there and terminates quickly. The main executable is locked only for short load periods, so the program file on disk remains in a state where it can be overwritten (with retries, if required) for update purposes. Ideally, the per-user-copy of the program is stored in an temporary location which is periodically freed, so the harddisk will not be cluttered (for the above mentioned reasons, the 'user-copy' cannot delete itself while terminating...). Problems: I've discovered (anyone out there who can acknowledge this?) that a starpack cannot copy it's own executable with tcl commands like ''file copy'' or a ''open/read/put/close''-sequence (because as a result always the whole directory structure gets unpacked in the destination). Maybe it has something to do with the underlaying '''VFS'''-Implementation... one must use an ''external'' copy/xcopy etc. instead which treats the .exe like any other disk file. Put the following sequence near the very top of your main starpack script: set myself [info nameofexecutable] set mytemp [file join $::env(temp) [file tail $myself]] if {[string compare -nocase $myself $mytemp]} { set mytempP $::env(temp) if {[catch {exec -- [auto_execok xcopy] [file nativename $myself] [file nativename $mytempP] /Y} rc]} { tk_messageBox -type ok -title Fehler:\ -message "Copy failed:\n\n$rc\n" -icon error exit 253 } if {[catch {eval exec -- $mytemp $argv &} rc]} { tk_messageBox -type ok -title Fehler:\ -message "Exec failed:\n\n$rc\n" -icon error exit 252 } exit 0 } ''See http://permalink.gmane.org/gmane.comp.lang.tcl.starkit/2537'' ---- [Category Tclkit]