Here is the idea I have.
1. The program checks if there is a new copy of itself on a remote location.
2. If so then the program downloads the new copy with a temporary name.
3. Then the program creates a batch file that would delete the original, rename the new version and finally run the new version.
For this to work I need to run the batch file after the program exits (otherwise a file sharing error occurs). But I have no idea on how to do it. Does anyone has a brainstorm on how to do it?
:: ------------------------------------------------------------------
:: Batchfile : SLEEP.BAT
:: Funktion : Batch File Wait
:: OS : MS-DOS 5+
:: Updated : Frank-Peter Schultze , 20010528
:: ------------------------------------------------------------------
@echo off
if %OS%/==Windows_NT/ (echo MS-DOS/Windows 9x Batch File.&goto :EOF)
if NOT /==/%1 if NOT /?/==/%1/ goto :Begin
echo Batch File Wait.
echo.
echo %0 Delay
echo.
echo Delay Time to sleep in seconds (1-99).
echo Message Message to be echoed to the console.
for %%C in (echo. goto:End) do %%C
:Begin --------------------------------------------------------------
set DLY=%1
if %DLY%/==0/ for %%C in (echo goto:End) do %%C illegal: %DLY%
if /==/%2 goto Sleep
for %%C in (set shift) do %%C MSG=%2
:Loop
if NOT %2/==/ for %%C in (set shift goto:Loop) do %%C MSG=%MSG% %2
:Sleep
rem | CHOICE /N /Cÿ /Tÿ,%DLY% %MSG%
:End ----------------------------------------------------------------
for %%V in (DLY MSG) do set %%V=
Hope, this helps :Dmy advice: have the main program CreateProcess an "updater" program which will do the deleting/replacing. that way you have more control over things - you can check whether the old program has terminated and if not wait for it to finish.
Thanks for your prompt repply! :)