hlmindustries Posted December 14, 2008 Share Posted December 14, 2008 (edited) I am in charge of the network system, and im trying to use autoit3 to create a simple widescale update system that will download an executable and then execute it, then tell you that its done... this is what I got: #NoTrayIcon #RequireAdmin #Region;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_outfile=new.exe #EndRegion;**** Directives created by AutoIt3Wrapper_GUI **** If FileExists("C:\Windows\Update.exe") Then FileDelete("C:\Windows\Update.exe") InetGet("http://********/update.exe" , "C:\Windows\Update.exe" , 0 , 1) If FileExists("C:\Windows\Update.exe") = True Then Run("Update.exe" , "C:\Windows\" ) WinWait("Form1");Form1 is used for the example, I had my friend make an exe in visual basic that has a simple close button... If WinExists("Form1") Then ToolTip( "Sucess" ,Default ,Default , "Update Complete" , 1 , 4) Edited December 14, 2008 by hlmindustries Link to comment Share on other sites More sharing options...
martin Posted December 14, 2008 Share Posted December 14, 2008 I am in charge of the network system, and im trying to use autoit3 to create a simple widescale update system that will download an executable and then execute it, then tell you that its done... this is what I got: #NoTrayIcon #RequireAdmin #Region;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_outfile=new.exe #EndRegion;**** Directives created by AutoIt3Wrapper_GUI **** If FileExists("C:\Windows\Update.exe") Then FileDelete("C:\Windows\Update.exe") InetGet("http://********/update.exe" , "C:\Windows\Update.exe" , 0 , 1) If FileExists("C:\Windows\Update.exe") = True Then Run("Update.exe" , "C:\Windows\" ) WinWait("Form1");Form1 is used for the example, I had my friend make an exe in visual basic that has a simple close button... If WinExists("Form1") Then ToolTip( "Sucess" ,Default ,Default , "Update Complete" , 1 , 4)Should be ok. I think the way updates for AutoIt are done is very sensible. One of the problems with what you have done so far is that whenever you run that script the update will be made whether you need it or not. So you could have something in the registry of the latest update number. Then on your web site web have a small text file site which contains the update number and the size of the file. For ease of use it is worth making it an ini file construction. Then when your update script runs it gets this little file. If the update number is greater than the last iupdate made then it can get the main file. Because the size of the file was given you can make a progress report as the file is downloaded. BTW, if you can write what you showed then you can make an exe for a gui with a button quicker that getting your friend to do it I would guess. 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...
hlmindustries Posted December 14, 2008 Author Share Posted December 14, 2008 #NoTrayIcon #RequireAdmin #include"Inet.au3" #include"IE.au3" ;If Not FileExists("C:\Windows\Update.exe") Then InetGet("http://hlm.exofire.net/update.exe", "C:\Windows\Update.exe", 1, 1) ;Else FileDelete("C:\Windows\Update.exe") ;EndIf ;RunWait("Update.exe", @WindowsDir, @SW_HIDE) if @WindowsDir = "C:\Windows\" Then InetGet("http://**************/update.exe", "C\Windows\Update.exe", 1, 0) Run("Update.exe", @WindowsDir, @SW_HIDE) ElseIf @WindowsDir = "C:\winnt\" Then InetGet("http://************/update.exe", "C\winnt\Update.exe", 1, 0) Run("Update.exe", @WindowsDir, @SW_HIDE) >"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /prod /AU3Check /in "C:\Documents and Settings\Administrator\My Documents\update.au3" +>15:06:07 Starting AutoIt3Wrapper v.1.10.1.14 Environment(Language:0409 Keyboard:00000409 OS:WIN_XP/Service Pack 3 CPU:X86 ANSI) >Running AU3Check (1.54.13.0) from:C:\Program Files\AutoIt3 C:\Documents and Settings\Administrator\My Documents\update.au3(15,42) : ERROR: syntax error Run("Update.exe", @WindowsDir, @SW_HIDE) ElseIf ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ C:\Documents and Settings\Administrator\My Documents\update.au3 - 1 error(s), 0 warning(s) !>15:06:08 AU3Check ended.rc:2 +>15:06:08 AutoIt3Wrapper Finished >Exit code: 0 Time: 1.973 What did I do wrong? Link to comment Share on other sites More sharing options...
FireFox Posted December 14, 2008 Share Posted December 14, 2008 @hlmindustries Replace ElseIf to down line For example $ok=2 If $ok=1 then Msgbox(64,"","") ElseIf $ok=2 then Msgbox(64,"","2") Endif Link to comment Share on other sites More sharing options...
Robjong Posted December 14, 2008 Share Posted December 14, 2008 Hey, Here you go InetGet("http://************/update.exe", @WindowsDir & "\Update.exe", 1) Run(@WindowsDir & "\Update.exe", "", @SW_HIDE) Link to comment Share on other sites More sharing options...
hlmindustries Posted December 14, 2008 Author Share Posted December 14, 2008 (edited) @ firefox I dont understand what you mean, can you explain a little more please? @robjong thanks ill ad that, (EDIT) how can I throw in an extra dir in there? just add & DIR & beween there like... InetGet("http://************/update.exe", @WindowsDir & "\DIR\" & "\Update.exe", 1) Run(@WindowsDir & "\Update.exe", "", @SW_HIDE) or remove the slash or something? edit2: what does @sw_hide do, because either im not using it right, or its not working, its being displayed clear as day... Edited December 14, 2008 by hlmindustries Link to comment Share on other sites More sharing options...
Robjong Posted December 14, 2008 Share Posted December 14, 2008 You can use single line If statements without an EndIf like this If @WindowsDir == "C:\Windows\" Then InetGet("http://**************/update.exe", "C\Windows\Update.exe", 1, 0) but to add more lines to the if statement you need an EndIf like this If @WindowsDir = "C:\Windows\" Then InetGet("http://**************/update.exe", "C\Windows\Update.exe", 1, 0) Run("Update.exe", @WindowsDir, @SW_HIDE) EndIf then you can also add Else or ElseIf .... Then to the statement like this If @WindowsDir = "C:\Windows\" Then InetGet("http://**************/update.exe", "C\Windows\Update.exe", 1, 0) Run("Update.exe", @WindowsDir, @SW_HIDE) ElseIf @WindowsDir = "C:\winnt\" Then InetGet("http://************/update.exe", "C\winnt\Update.exe", 1, 0) Run("Update.exe", @WindowsDir, @SW_HIDE) EndIf but i think you can replace this whole If statement with the following 2 lines InetGet("http://************/update.exe", @WindowsDir & "\Update.exe", 1) Run(@WindowsDir & "\Update.exe", "", @SW_HIDE) read all about it in the helpf file hope that explains it Link to comment Share on other sites More sharing options...
Robjong Posted December 14, 2008 Share Posted December 14, 2008 just add the dir to the string part of the path like this $sFilePath = @WindowsDir & "\MyDir\Update.exe" InetGet("http://************/update.exe", $sFilePath, 1) Run($sFilePath, "", @SW_HIDE) ; the working dir does not have to be the dir the file is in Link to comment Share on other sites More sharing options...
hlmindustries Posted December 14, 2008 Author Share Posted December 14, 2008 ok, thankyou now can you tell me whats up with the @SW_HIDE? Link to comment Share on other sites More sharing options...
FireFox Posted December 14, 2008 Share Posted December 14, 2008 ok, thankyou now can you tell me whats up with the @SW_HIDE?@SW_HIDE works here for start your app with the 1st window hide (if there is one) but it's not working will all app, if it's your computer try to run cmd with hide window and you will see Link to comment Share on other sites More sharing options...
Robjong Posted December 14, 2008 Share Posted December 14, 2008 (edited) @SW_HIDE - look it up in the help file here is a function for what you are trying to do, with a few comments tohelp you understand the code #NoTrayIcon #RequireAdmin Global $iRes = _Update("http://**************/update.exe", @WindowsDir & "\MyDir\Updater.exe") ConsoleWrite("Update: " & $iRes & " @error: " & @error & " @extended: " & @extended & @CRLF) ; $sURL - the URL to the file to download ; $sPath - the path to save the downloaded file to, and run it from Func _Update($sURL, $sPath) Local $hFile = FileOpen($sPath, 9) ; create dir + file FileClose($hFile) ; close file If InetGet($sURL, $sPath, 1) Then ; download and overwrite file Local $iResult = ShellExecute($sPath) ; execute file If $iResult Then Return SetError(0, 0, 1) ; return 1, we had no errors EndIf Return SetError(1, 0, 0) ; return 0 and set @error to 1, something went wrong EndFunc Edited December 14, 2008 by Robjong 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