Mamba Posted December 12, 2006 Share Posted December 12, 2006 (edited) I want to make an automate update, but i stuck on how to find the size of file without the size of filename. On the server i keep file with a common name, but the user may change the name of his copy of program. So i'm wondering how to make a script like this if InetGetSize("File_URL") - Size in Bytes of common name <> FileSize(@ScriptName) - Size in Bytes of @ScriptName then Do the Update. Tnx for your suggestions. Edited December 12, 2006 by Mamba Link to comment Share on other sites More sharing options...
martin Posted December 12, 2006 Share Posted December 12, 2006 I want to make an automate update, but i stuck on how to find the size of file without the size of filename. On the server i keep file with a common name, but the user may change the name of his copy of program. So i'm wondering how to make a script like thisif InetGetSize("File_URL") - Size in Bytes of common name <> FileSize(@ScriptName) - Size in Bytes of @ScriptName then Do the Update.Tnx for your suggestions.I would tell the customer that if he wants to rename the file then he must remember to rename the update. Presumably there is a good reason to rename the file, but it sounds like a very bad idea to me.If I had a situation where renaming an exe was required then I would provide a method for the customer rather than have him rename the file himself, and in this method I would write the new name in the registry. You then tell the customer that if he wants to rename the exe he must do it this way or he will be plagued by locusts. Then, when you download the file you can look up what to rename it to. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Joon Posted December 12, 2006 Share Posted December 12, 2006 (edited) Slightly modified SuiCide UDF. - Not Tested. $SC_File = @TempDir & "\Update.bat" If InetGetSize($url) <> FileGetSize(@ScriptFullPath) Then InetGet($url,@ScriptDir & $tempname) $SC_batch = 'loop:' & @CRLF & _ 'del "' & @ScriptFullPath & '"' & @CRLF & _ 'ping -n 1 -w 250 zxywqxz_q' & @CRLF & _ 'if exist "' & @ScriptFullPath & '" goto loop' & @CRLF & _ 'loop2:' & @CRLF & _ 'ping -n 1 -w 250 zxywqxz_q' & @CRLF & _ 'rename "' & @ScriptDir & $tempname & '" ' & '"' & @ScriptName & '"' & @CRLF & _ 'if not exist "' & @ScriptFullPath & '" goto loop2' & @CRLF & _ 'del Update.bat' & @CRLF FileWrite($SC_File, $SC_batch) Run($SC_File, @TempDir, @SW_HIDE) EndIf Edited December 12, 2006 by Joon Link to comment Share on other sites More sharing options...
Mamba Posted December 12, 2006 Author Share Posted December 12, 2006 Slightly modified SuiCide UDF. - Not Tested. $SC_File = @TempDir & "\Update.bat" If InetGetSize($url) <> FileGetSize(@ScriptFullPath) Then InetGet($url,@ScriptDir & $tempname) $SC_batch = 'loop:' & @CRLF & _ 'del "' & @ScriptFullPath & '"' & @CRLF & _ 'ping -n 1 -w 250 zxywqxz_q' & @CRLF & _ 'if exist "' & @ScriptFullPath & '" goto loop' & @CRLF & _ 'loop2:' & @CRLF & _ 'ping -n 1 -w 250 zxywqxz_q' & @CRLF & _ 'rename "' & @ScriptDir & $tempname & '" ' & '"' & @ScriptName & '"' & @CRLF & _ 'if not exist "' & @ScriptFullPath & '" goto loop2' & @CRLF & _ 'del Update.bat' & @CRLF FileWrite($SC_File, $SC_batch) Run($SC_File, @TempDir, @SW_HIDE) EndIf Tnx, i'll test it right now Link to comment Share on other sites More sharing options...
Mamba Posted December 12, 2006 Author Share Posted December 12, 2006 (edited) It's working, but not for all people. I think InetGetSize is not the best way to check for an update Edited December 12, 2006 by Mamba Link to comment Share on other sites More sharing options...
Xander Posted January 5, 2007 Share Posted January 5, 2007 My main script was set to compare its local self to its online version by using InetGetSize. Unfortunately, it would sometimes get stuck in an updating loop when comparing the file sizes (even after it had just updated and was comparing identical files).As a result, I've recently taken to using a INI file of sorts and keeping it online. It contains the date of the last real update and, once downloaded to the TempDir, is compared with the local copy of the INI. If the dates don't match, the update is done and the local INI gets new dates. When I finish compiling my scripts, each is set to run the 'updated the INI' program when compiling ends. Then, when I'm ready to upload the new EXE, I upload the new INI with them.Working like a charm so far. Link to comment Share on other sites More sharing options...
McGod Posted January 5, 2007 Share Posted January 5, 2007 Just use an ini file. [Update] LastUpdateTime=2006/07/06 LatestUpdateVer=1.3 [indent][center][u]Formerly Chip[/u][/center]~UDFs~[/indent][u]IRC.au3 - Allows you to connect to IRC ServersINetCon.au3 - Connects/Disconnects/Check Status of InternetHardware Key - Creates a unique hardware hashScriptComm - Allows you to communicate between scripts using WM_COPYDATA[/u][indent]~Programs~[/indent][indent]SimonAu3ForumsIRC Bot~Web Site~Web Autoit Example[/indent][indent][b][/b][/indent][u][/u] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now