SeF Posted January 5, 2010 Share Posted January 5, 2010 Hello!I created an auto-updater script that runs fine on a LAN network...The Script:expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> ;>>>>>>>>>>>>>>>UPDATE>>>>>>>>>>>>>>>>>>>> $CurrentVersion = FileGetVersion(@ScriptFullPath) $LastVersion = FileGetVersion("\\COMPANY'S NETWORK\AUTOMATIZATION SOFTWARES\" & @ScriptName) If $CurrentVersion < $LastVersion Then $Form1 = GUICreate("Auto SAP - Updater", 315, 91, 233, 196) $Progress1 = GUICtrlCreateProgress(8, 56, 300, 17) $Label3 = GUICtrlCreateLabel("Silvio Lobo", 256, 78, 56, 12) GUICtrlSetColor(-1, 0x808080) $Label1 = GUICtrlCreateLabel("Update in progress . . .", 8, 16, 300, 50) GUISetState(@SW_SHOW) GUICtrlSetData($Progress1, 0) sleep(100) GUICtrlSetData($Progress1, 10) sleep(100) GUICtrlSetData($Progress1, 20) sleep(50) FileCopy("\\COMPANY'S NETWORK\AUTOMATIZATION SOFTWARES\" & @ScriptName, @ScriptDir & "\NEW.exe") GUICtrlSetData($Progress1, 30) sleep(50) GUICtrlSetData($Progress1, 40) sleep(50) GUICtrlSetData($Progress1, 50) FileMove(@ScriptFullPath, @ScriptDir & "\OLD.exe") GUICtrlSetData($Progress1, 60) sleep(50) GUICtrlSetData($Progress1, 70) sleep(50) FileMove(@ScriptDir & "\NEW.exe", @ScriptFullPath) GUICtrlSetData($Progress1, 80) sleep(50) GUICtrlSetData($Progress1, 90) FileDelete(@ScriptDir & "\OLD.exe") GUICtrlSetData($Progress1, 100) sleep(500) Run(@ScriptName) Exit EndIf(I know that the sleep's are unnecessary. I just added for making the update takes a little longer to make things more visible to the user)Script without the progressbar:$CurrentVersion = FileGetVersion(@ScriptFullPath) $LastVersion = FileGetVersion("\\COMPANY'S NETWORK\AUTOMATIZATION SOFTWARES\" & @ScriptName) If $CurrentVersion < $LastVersion Then FileCopy("\\COMPANY'S NETWORK\AUTOMATIZATION SOFTWARES\" & @ScriptName, @ScriptDir & "\NEW.exe") FileMove(@ScriptFullPath, @ScriptDir & "\OLD.exe") FileMove(@ScriptDir & "\NEW.exe", @ScriptFullPath) FileDelete(@ScriptDir & "\OLD.exe") Run(@ScriptName) Exit EndIfI just want some suggestions to improve my script, specially with the progressbar Thanks! Link to comment Share on other sites More sharing options...
tlman12 Posted January 5, 2010 Share Posted January 5, 2010 so this file is updating itself? does it do anything else? i don't think this will work because your have the script try to delete itself while it's running. i had the same problem when i ventured into auto updating one of my scripts. i ended up writing a separate process to do it, which was simple and allowed me to easily change features of the updater as well as the script without having to send out an e-mail everytime script was updated Link to comment Share on other sites More sharing options...
SeF Posted January 5, 2010 Author Share Posted January 5, 2010 (edited) so this file is updating itself? does it do anything else?i don't think this will work because your have the script try to delete itself while it's running.i had the same problem when i ventured into auto updating one of my scripts. i ended up writing a separate process to do it, which was simple and allowed me to easily change features of the updater as well as the script without having to send out an e-mail everytime script was updatedUpdates itself. (Kinda off...)He just copy the new version, rename the actual, rename the new one and delete the old one(actual).I can't explain how it works (Because, it's like you said...The script delete itself during the process).But, it's working very nicely on my work. He checks for an update, If there is one...It updates and re-open the program again.I put this script at the beginning of all my programs. Edited January 5, 2010 by SeF Link to comment Share on other sites More sharing options...
failedtocompile Posted January 5, 2010 Share Posted January 5, 2010 (edited) you can look at this method for creating a progress bar and include this in your script. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ProgressConstants.au3> #include <SendMessage.au3> $Form1 = GUICreate("progress123", 198, 19, 820, 512, BitOR($WS_SYSMENU,$WS_DLGFRAME,$WS_POPUP,$WS_CLIPSIBLINGS)) GUISetState(@SW_SHOW) GUICtrlCreateProgress(-1, -1, 200, 20, $PBS_MARQUEE) _SendMessage(GUICtrlGetHandle(-1), $PBM_SETMARQUEE, True, 50) GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd ftc Edited January 5, 2010 by failedtocompile Link to comment Share on other sites More sharing options...
SeF Posted January 6, 2010 Author Share Posted January 6, 2010 you can look at this method for creating a progress bar and include this in your script. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ProgressConstants.au3> #include <SendMessage.au3> $Form1 = GUICreate("progress123", 198, 19, 820, 512, BitOR($WS_SYSMENU,$WS_DLGFRAME,$WS_POPUP,$WS_CLIPSIBLINGS)) GUISetState(@SW_SHOW) GUICtrlCreateProgress(-1, -1, 200, 20, $PBS_MARQUEE) _SendMessage(GUICtrlGetHandle(-1), $PBM_SETMARQUEE, True, 50) GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd ftc It worked just fine! Thanks! 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