magace Posted November 26, 2013 Posted November 26, 2013 (edited) Hi I am currently trying to create a little auto updater for a script. I want to download the update from my ftp server. I found this guys post and it works kinda however it gets a error "autoit v3 script has stoped working" after it successfully downloads the file. '?do=embed' frameborder='0' data-embedContent>> Any idea on what the guy did to fix it since he did not post the fixed version. Here is my code and again it works but force closes after downloading the file so I can't finish it ;run new script.exe Thanks! expandcollapse popup#include <FTP.au3> $SaveLogsPath = @AppDataDir & "\" $server = 'xxx' $username = 'xxx' $pass = 'xxx' $process = "script.exe" $srcPath = "/" $filename = "script.exe" Update() Func Update() ToolTip("Checking to see if script is running...",0,0) sleep(1000) If ProcessExists($process) Then ProcessClose($process) ToolTip("script IS TERMINATED",0,0) sleep(1000) EndIf ToolTip("Checking to see if script is installed...",0,0) sleep(1000) If FileExists($SaveLogsPath & "script.exe") Then ToolTip("script is installed deleting it before reinstall...",0,0) sleep(1000) FileDelete($SaveLogsPath & "script.exe") ToolTip("Downloading new update...",0,0) sleep(1000) $dllhandle = DllOpen('wininet.dll') $Open = _FTPOpen('MyFTP Control') $Conn = _FTPConnect($Open, $server, $username, $pass) $Ftpp = _FTPGetFile($Conn, $srcPath & $filename, $SaveLogsPath & '\' & $filename,1,0) $Ftpc = _FTPClose($Open) DllClose($dllhandle) ToolTip("Installing new update...",0,0) sleep(1000) ;run new script.exe Else ToolTip("script not installed lets download and install...",0,0) sleep(1000) $dllhandle = DllOpen('wininet.dll') $Open = _FTPOpen('MyFTP Control') $Conn = _FTPConnect($Open, $server, $username, $pass) $Ftpp = _FTPGetFile($Conn, $srcPath & $filename, $SaveLogsPath & '\' & $filename,1,0) $Ftpc = _FTPClose($Open) DllClose($dllhandle) ToolTip("Installing new update...",0,0) sleep(1000) ;run new script.exe EndIf EndFunc Func _FTPGetFile($l_FTPSession, $s_LocalFile, $s_RemoteFile, $l_Flags = 1, $l_Context = 0) Local $ai_FTPGetFile = DllCall('wininet.dll', 'int', 'FtpGetFile', 'long', $l_FTPSession, 'str', $s_LocalFile, 'str', $s_RemoteFile, 'long', $l_Flags, 'long', $l_Context) If @error OR $ai_FTPGetFile[0] = 0 Then SetError(-1) Return 0 EndIf Return $ai_FTPGetFile[0] EndFunc;==> _FTPGetFile() Edited November 26, 2013 by magace
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