Guest User

bene

a guest
Sep 30th, 2009
660
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #NoTrayIcon
  2. #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
  3. #AutoIt3Wrapper_icon=system-software-update.ico
  4. #AutoIt3Wrapper_outfile=Updater.exe
  5. #AutoIt3Wrapper_UseUpx=n
  6. #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
  7. #Region
  8. #EndRegion
  9.  
  10. #include <GUIConstantsEx.au3>
  11. #include <StaticConstants.au3>
  12. #include <WindowsConstants.au3>
  13. #include <ProgressConstants.au3>
  14. #include <HTTP.au3>
  15.  
  16. ; updater nur einmal starten
  17. #include <misc.au3>
  18. If _Singleton("Updater.exe", 0) = 0 Then
  19.     ProcessClose("Updater.exe")
  20. EndIf
  21.  
  22. ; chrome prozess schliessen
  23. ProcessClose( "chrome.exe" )
  24.  
  25. ; GUI für die Auswahl ob Beta oder Release Channel
  26. GUICreate( "Chrome Updater", 320, 75 )
  27. Opt( "GUICoordMode",2 )
  28. $dev = GUICtrlCreateButton ( "Dev Channel",  10, 30, 100 )
  29. $beta = GUICtrlCreateButton ( "Beta Channel",  0, -1 )
  30. $release = GUICtrlCreateButton ( "Release Channel",  0, -1 )
  31. GUISetState()
  32.  
  33. ; GUI laufen lassen bis geschlossen wird
  34. While 1
  35.     $msg = GUIGetMsg()
  36.     Select
  37.         Case $msg = $GUI_EVENT_CLOSE
  38.             ExitLoop
  39.         Case $msg = $dev
  40.             ; 1 weiergeben an updater funktion fuer beta channel
  41.             Updater(1)
  42.         Case $msg = $beta
  43.             ; 2 weitergeben an updater funktion fuer release channel
  44.             Updater(2)
  45.         Case $msg = $release
  46.             ; 3 weitergeben an updater funktion fuer release channel
  47.             Updater(3)
  48.     EndSelect
  49. WEnd
  50.  
  51. Func Updater($channel)
  52.     ; gui schliessen
  53.     GUIDelete()
  54.  
  55.     ; update ordner anlegen
  56.     DirCreate( @ScriptDir&"\Update" )
  57.  
  58.     ; updates ordner anlegen für versionskontrolle
  59.     DirCreate( @ScriptDir&"\Chrome\updates" )
  60.  
  61.     ; aktuellen chrome ermitteln
  62.     $host='tools.google.com'
  63.     $port=80
  64.     $page='/service/update2'
  65.     _HTTPSetUserAgent("Google Update", "1.2.183.7;winhttp")
  66.     $socket=_HTTPConnect($host, $port)
  67.  
  68.     If $channel = 1 Then
  69.         ;Dev-Channel
  70.         $data='<?xml version="1.0" encoding="UTF-8"?><o:gupdate xmlns:o="http://www.google.com/update2/request" protocol="2.0" version="1.2.183.7" ismachine="0" machineid="{11111111-1111-1111-1111-111111111111}" userid="{11111111-1111-1111-1111-111111111111}" requestid="{11111111-1111-1111-1111-111111111111}"><o:os platform="win" version="5.1" sp="Service Pack 3"/><o:app appid="{8A69D345-D564-463C-AFF1-A69D9E530F96}" version="" lang="de" brand="" client="" iid="{11111111-1111-1111-1111-111111111111}"><o:updatecheck tag="2.0-dev"/></o:app></o:gupdate>'
  71.     ElseIf $channel = 2 Then
  72.         ;Beta-Channel
  73.         $data='<?xml version="1.0" encoding="UTF-8"?><o:gupdate xmlns:o="http://www.google.com/update2/request" protocol="2.0" version="1.2.183.7" ismachine="0" machineid="{11111111-1111-1111-1111-111111111111}" userid="{11111111-1111-1111-1111-111111111111}" requestid="{11111111-1111-1111-1111-111111111111}"><o:os platform="win" version="5.1" sp="Service Pack 3"/><o:app appid="{8A69D345-D564-463C-AFF1-A69D9E530F96}" version="" lang="de" brand="" client="" iid="{11111111-1111-1111-1111-111111111111}"><o:updatecheck tag="1.1-beta"/></o:app></o:gupdate>'
  74.     ElseIf $channel = 3 Then
  75.         ;Final-Channel
  76.         $data='<?xml version="1.0" encoding="UTF-8"?><o:gupdate xmlns:o="http://www.google.com/update2/request" protocol="2.0" version="1.2.183.7" ismachine="0" machineid="{11111111-1111-1111-1111-111111111111}" userid="{11111111-1111-1111-1111-111111111111}" requestid="{11111111-1111-1111-1111-111111111111}"><o:os platform="win" version="5.1" sp="Service Pack 3"/><o:app appid="{8A69D345-D564-463C-AFF1-A69D9E530F96}" version="" lang="de" brand="" client="" iid="{11111111-1111-1111-1111-111111111111}"><o:updatecheck/></o:app></o:gupdate>'
  77.     EndIf
  78.  
  79.     _HTTPPost( $host, $page, $socket, $data )
  80.     $body=_HTTPRead( $socket, 0 )
  81.     $position=StringInStr( $body,"codebase=" )
  82.     $urltmp=StringMid( $body,$position+10,Stringlen($body)-$position-10 )
  83.     $url=StringSplit( $urltmp,'"' )
  84.     $update_url = $url[1]
  85.  
  86.     ; url splitten und version aus der url auslesen
  87.     $v_temp = StringSplit( $update_url, "/" ,0 )
  88.     $version = $v_temp[7]
  89.     ; falls versionsdatei existiert, updateurl zurücksetzen
  90.     If FileExists( @ScriptDir&"\Chrome\updates\"&$version&".txt" ) Then $update_url = ""
  91.  
  92.     ; nichts gefunden, beenden
  93.     If Not $update_url Then
  94.         If @OSLang = 0407 Then
  95.             MsgBox( 0,"Chrome Updater","Keine neue Version gefunden!" )
  96.         Else
  97.             MsgBox( 0,"Chrome Updater","No new version available!" )
  98.         EndIf
  99.         DirRemove( @ScriptDir&"\Update", 1)
  100.         Exit
  101.     EndIf
  102.  
  103.     ; progress fenster
  104.     $window = GUICreate( "Chrome Download", 306, 40 )
  105.     $progressbar = GUICtrlCreateProgress( 9, 15, 286, 17 )
  106.     GUISetState( @SW_SHOW )
  107.  
  108.     ; dateigröße
  109.     $fileSize = InetGetSize( $update_url )
  110.  
  111.     ; setup holen
  112.     InetGet ( $update_url, @ScriptDir&"\Update\chrome_aktuell.exe" ,0 ,1 )
  113.  
  114.     ; progressfenster "refreshen", balken fortlaufend
  115.     While @InetGetActive
  116.         $percent = Round( ((@InetGetBytesRead / $fileSize) * 100) ) & "%"
  117.         GUICtrlSetData( $progressbar, $percent )
  118.         $msg = GUIGetMsg()
  119.         ; falls progressfenster geschlossen wird, Download abbrechen, Update Ordner löschen und dann Exit
  120.         if $msg = $GUI_EVENT_CLOSE then
  121.             InetGet( "abort" )
  122.             DirRemove( @ScriptDir&"\Update", 1)
  123.             Exit
  124.         EndIf
  125.         Sleep(10)
  126.     WEnd
  127.  
  128.     ; gui schliessen
  129.     GUIDelete()
  130.  
  131.     ; 7za.exe inkludieren
  132.     FileInstall( "7za.exe", @ScriptDir&"\" )
  133.  
  134.     ; setup entpacken
  135.     RunWait( "7za.exe x """&@ScriptDir&"\Update\chrome_aktuell.exe"" -o"""&@ScriptDir&"\Update""" )
  136.  
  137.     ; chrome.7z entpacken
  138.     RunWait( "7za.exe x """&@ScriptDir&"\Update\chrome.7z"" -o"""&@ScriptDir&"\Update\extracted""" )
  139.  
  140.     ; alles aus dem versionsnummern ordner in den Chrome Ordner
  141.     $first = FileFindFirstFile( @ScriptDir&"\Update\extracted\Chrome-bin\*.*" )
  142.     $versions_ordner = FileFindNextFile( $first )
  143.     FileClose( $first )
  144.     DirCopy( @ScriptDir&"\Update\extracted\Chrome-bin\"&$versions_ordner&"\", @ScriptDir&"\Chrome\", 1 )
  145.  
  146.     ; restlichen Dateien und Ordner
  147.     FileCopy( @ScriptDir &"\Update\extracted\chrome.exe", @ScriptDir&"\Chrome\" ,1 )
  148.     DirCopy( @ScriptDir &"\Update\extraced\Dictionaries", @ScriptDir&"\Chrome\" ,1 )
  149.  
  150.     ; alles aufräumen
  151.     FileDelete( @ScriptDir &"\7za.exe" )
  152.     DirRemove( @ScriptDir &"\Update\" , 1 )
  153.  
  154.     ; versions datei nach Chrome\updates schreiben
  155.     $av_temp = FileFindFirstFile( @ScriptDir&"\Chrome\updates\*.txt" )
  156.     $alte_version = FileFindNextFile( $av_temp )
  157.     FileClose( $av_temp )
  158.     FileDelete( @ScriptDir&"\Chrome\updates\"&$alte_version )
  159.     FileWrite( @ScriptDir&"\Chrome\updates\"&$version&".txt", "" )
  160.  
  161.     ; message Box ausgeben wenn mit Update fertig
  162.     If @OSLang = 0407 Then
  163.         MsgBox( 0,"Chrome Updater","Chrome wurde aktualisiert" )
  164.     Else
  165.         MsgBox( 0,"Chrome Updater","Chrome updated" )
  166.     EndIf
  167.     ; updater beenden
  168.     Exit
  169. EndFunc
  170.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×