If anyone has an example I'd enjoy seeing it.
I'm going to attempt an auto update to my program, just a Macro Scheduler .exe file.
For example the program is located on c:\program files\myprogram.
The latest revision is located on a network share m:\myprogram.
When I launch the local program, one of the first things I'd like to do is have it do a check for a newer version and if so close it's self and copy the updated version.
Open program checks for newer program.(using filedate and filesize to compare the 2 files.)
If they do not match call update program(update.exe)
Close the calling program.
Delete c: program and copy from m:.
Call c: drive program and close the calling program.
Regards,
Frank
.exe Macro checking for a newer version of it's self.
Moderators: JRL, Dorian (MJT support)
-
- Newbie
- Posts: 8
- Joined: Mon May 01, 2006 6:27 pm
I'm doing this with several .exes. Using the comparison technique at the end of this post. I run an exe that calls an exe. I can't post the exes because they're too specific to my application (and lengthy) Here's the sequence of events
- Exe one is selected by user
- Exe two is on the network and is on the users computer.
- The following technique compares the two files
- If they are different, or if the local exe does not exist, the network Exe is copied over the local exe. When the copy is complete, the local exe is run.
- If the files are the same, the local Exe is run.
I also have written an exe that overwrites itself, It creates a batch file that then deletes the old exe, copies the new exe, then calls the new exe. It seems to work but I don't trust it. I don't want to do all the error checking needed if there is an interruption mid copy. Once the Exe is deleted if the process does not complete there is no longer an exe for the user to call, so you have to set up the computer to look for the exe on startup and replace it if its gone, or look for the existance of the batch file and run it if it exists. Too may places for failure to occur.
Hope this is helpful,
Dick
- Exe one is selected by user
- Exe two is on the network and is on the users computer.
- The following technique compares the two files
- If they are different, or if the local exe does not exist, the network Exe is copied over the local exe. When the copy is complete, the local exe is run.
- If the files are the same, the local Exe is run.
I also have written an exe that overwrites itself, It creates a batch file that then deletes the old exe, copies the new exe, then calls the new exe. It seems to work but I don't trust it. I don't want to do all the error checking needed if there is an interruption mid copy. Once the Exe is deleted if the process does not complete there is no longer an exe for the user to call, so you have to set up the computer to look for the exe on startup and replace it if its gone, or look for the existance of the batch file and run it if it exists. Too may places for failure to occur.
Hope this is helpful,
Dick
Code: Select all
Input>file1,Pick first file to compare
Input>file2,Pick second file to compare
Let>MSG_WIDTH=800
Let>RP_WAIT=1
GetTime>StartTime
Run>cmd /c echo N | comp "%file1%" "%file2%" > %TEMP_DIR%~compare_results~.txt
ReadFile>%TEMP_DIR%~compare_results~.txt,comp_result_file
Separate>comp_result_file,%CRLF%,var
Let>comp_result=%var_2%
GetTime>EndTime
If>%comp_result%=Files compare OK,same,notsame
Label>same
MDL>The files: %file1%%CRLF% and: %file2%%CRLF%%CRLF%Are identical.%CRLF%Compare time(%StartTime% to %EndTime%)
Goto>finish
Label>notsame
MDL>The files: %file1%%CRLF% and: %file2%%CRLF%%CRLF%Are different.%CRLF%Compare time (%StartTime% to %EndTime%)%CRLF%%CRLF%Comparison Information:%CRLF%%comp_result_file%
Label>finish
-
- Newbie
- Posts: 8
- Joined: Mon May 01, 2006 6:27 pm
Thanks again, I've posted what you wrote with a few modifications and some remarks.
This is working like a charm for my photocopy.exe.
Rem>from and to file for comparison
Let>file1=m:\photocopy.exe Rem>ORDER IS IMPORTANT
Let>file2=c:\photocopy.exe
Rem>It looks good?
Let>RP_WAIT=1
GetTime>StartTime
Run>cmd /c echo N | comp "%file1%" "%file2%" > %TEMP_DIR%~compare_results~.txt
ReadFile>%TEMP_DIR%~compare_results~.txt,comp_result_file
Separate>comp_result_file,%CRLF%,var
Let>comp_result=%var_2%
GetTime>EndTime
If>%comp_result%=Files compare OK,same,notsame
Rem>Not much here it could be removed but was left it in case anyone wanted to add conditions
Label>same
Goto>finish
Rem>If the comparison fails this is run
Label>notsame
deletefile>c:\photocopy.exe
copyfile>m:\photocopy.exe,c:\photocopy.exe
Label>finish
Rem>Program to be run which should now be at the latest version.
Run Program>c:\photocopy.exe
Label>end
This is working like a charm for my photocopy.exe.
Rem>from and to file for comparison
Let>file1=m:\photocopy.exe Rem>ORDER IS IMPORTANT
Let>file2=c:\photocopy.exe
Rem>It looks good?
Let>RP_WAIT=1
GetTime>StartTime
Run>cmd /c echo N | comp "%file1%" "%file2%" > %TEMP_DIR%~compare_results~.txt
ReadFile>%TEMP_DIR%~compare_results~.txt,comp_result_file
Separate>comp_result_file,%CRLF%,var
Let>comp_result=%var_2%
GetTime>EndTime
If>%comp_result%=Files compare OK,same,notsame
Rem>Not much here it could be removed but was left it in case anyone wanted to add conditions
Label>same
Goto>finish
Rem>If the comparison fails this is run
Label>notsame
deletefile>c:\photocopy.exe
copyfile>m:\photocopy.exe,c:\photocopy.exe
Label>finish
Rem>Program to be run which should now be at the latest version.
Run Program>c:\photocopy.exe
Label>end