Automatic update script, if anyone needs it.

Simple, Free, Open Source UltraVNC Wrapper Supporting Windows and Mac OSX.

Automatic update script, if anyone needs it.

Postby Znida » 2012-01-04 16:44

I wrote/modified a script, it autoupdates the .exe file from internet. If enyone needs it. it is an .au3 file.


Code: Select all

$url = "http://something.com/filename.exe"
$url2 = "http://something.com/filename.exe" ;second location if first fails

If InetGetSize($url) <> FileGetSize(@ScriptFullPath) and InetGetSize($url) > 10000 and $cmdline[0] = 0 Then 
   self_update($url)
elseIf InetGetSize($url2) <> FileGetSize(@ScriptFullPath) and InetGetSize($url2) > 10000 and $cmdline[0] = 0 Then 
   self_update($url2)
EndIf

Func self_update($update_url = "")
            
      $upd_dlsize = InetGetSize($update_url)
      
      ProgressOn("Nadgradnja ", "Nadgradnja programa ", "")
      Sleep(500)
      
      $upd_get = InetGet($update_url, @ScriptFullPath & ".new", 1, 1)
      Do
         ProgressSet(Round(InetGetInfo($upd_get, 0) / ($upd_dlsize / 100), 0), Floor(InetGetInfo($upd_get, 0) / 1024) & "kB od " & Floor($upd_dlsize / 1024) & "kB prenešeno." & @CRLF & "Prosimo počakajte...")
         Sleep(200)
      Until InetGetInfo($upd_get, 2)
         ProgressSet(Round(InetGetInfo($upd_get, 0) / ($upd_dlsize / 100), 0), Floor(InetGetInfo($upd_get, 0) / 1024) & "kB od " & Floor($upd_dlsize / 1024) & "kB prenešeno." & @CRLF & "Končano!")
      Sleep(1000)
            
        Local $batchPath = @ScriptDir & '\update.bat'
        Local $batchFile =  "ping localhost -n 2 > nul" & @CRLF _ ;not sure what you're doing here. Giving the script time to exit?
                          & ":loop" & @CRLF _ ;specify the start of a zone
                          & 'del /Q "' & @ScriptFullPath & '"' & @CRLF _ ;the quotes are needed for long filepaths, and filepaths with spaces. The @SciptfullPath is for flexibility
                          & 'if exist "' & @ScriptFullPath & '" goto loop' & @CRLF _ ;if the delete failed, try again
                          & 'move "' & @ScriptFullPath & '.new" "' & @ScriptFullPath & '"' & @CRLF _ ;this is why I changed the new file's name.
                          & '"' & @ScriptFullPath & '"' & @CRLF _
                    & 'del /Q "' & $batchPath & '"' & @CRLF _
                          & "exit"
                   
        FileWrite($batchPath,$batchFile)
        Run($batchPath, "", @SW_HIDE) ;
        Exit
EndFunc



just include a line in Instantsupport.au3 after other #includes

Code: Select all
#include "updateme.au3"


That's it. If you have some improvements, please do share :)
Znida
 
Posts: 5
Joined: 2012-01-04 16:02

Re: Automatic update script, if anyone needs it.

Postby supercoe » 2012-01-12 20:40

Good stuff, thanks for sharing! :)
http://www.chunkvnc.com - ChunkVNC - Free PC Remote control with the Open Source UltraVNC wrapper InstantSupport!
User avatar
supercoe
Super-Mod
Super-Mod
 
Posts: 1735
Joined: 2009-07-20 21:27
Location: Walker, MN


Return to ChunkVNC

Who is online

Users browsing this forum: No registered users and 5 guests

cron