Rackoon Posted October 19, 2013 Share Posted October 19, 2013 Hi, I try to create application what will: 1. download file after every 1 min. from http url (timer - not yet implemented) 2. compare downloaded and running file 3. if files are same, then delete downloaded (delete - not yet implemented) 4. if files are different then move downloaded over running 5. kill running windows application by process name (not yet implemented) 6. start windows application to reload new file (not yet implemented) ; Download configuration file. InetGet("http://192.168.56.101/autoit/config.php?did=2", "c:\_config.ini") ; Compare configuration file. IsFileSame("c:\_config.ini", "c:\config.ini") Func _IsFileSame($sFilePath_1, $sFilePath_2) Return RunWait(@ComSpec & ' /c FC /B /W "' & $sFilePath_1 & '" "' & $sFilePath_2 & '"', @WorkingDir, @SW_HIDE) = 0 EndFunc ; Copy new configuration file. If $_IsFileSame = False Then FileMove("C:\_config.ini", "C:\config.ini", 1) EndIf I don't understand what is wrong but I cannot run/compile solutsion... can someone please help me? Thanks. Link to comment Share on other sites More sharing options...
Solution FireFox Posted October 19, 2013 Solution Share Posted October 19, 2013 (edited) Hi, Welcome to the autoit forum Instead of downloading the file each time to compare it with your current one, it would be better to directly compare the file versions by a http request made either on a txt or on a php (which make a sql request) file. For the rest it's quite easy. Kill processes: ProcessList with ProcessClose (and compare pid (@AutoItPID) to avoid closing the current process) Compare files (versions will be enough): FileGetVersion with _VersionCompare And finally restart the application: Run/ShellExecute followed by Exit. Br, FireFox. Edited October 19, 2013 by FireFox Link to comment Share on other sites More sharing options...
Rackoon Posted October 20, 2013 Author Share Posted October 20, 2013 (edited) Hi FireFox, Thanks for warm welcome! Also thanks for advice about version check before download, I will think about it and when there is point in my system, I will implement it - less data to transfer --- For now I have solved my issues and application is doing what I need: #include <File.au3> ; Open the logfile in write mode. Local $hFile = FileOpen(@ScriptDir & "\application.log", 1) ; Download configuration file. InetGet("http://192.168.56.101/autoit/config.php?did=2", "c:\_config.ini") Sleep(1000) ; Compare configuration files. $version = _IsFileSame("c:\_config.ini", "c:\config.ini") Sleep(1000) ; Configuration control function. If $version = False Then FileMove("C:\_config.ini", "C:\config.ini", 1) _FileWriteLog($hFile, "Configuration changed") Run("stop.bat", "", @SW_MINIMIZE) Sleep(3000) _FileWriteLog($hFile, "Application closed") Run("start.bat", "", @SW_MINIMIZE) Sleep(3000) _FileWriteLog($hFile, "Application started") Else FileDelete ( "C:\_config.ini" ) EndIf Sleep(1000) ; Compare configuration function. Func _IsFileSame($sFilePath_1, $sFilePath_2) Return RunWait(@ComSpec & ' /c FC /B /W "' & $sFilePath_1 & '" "' & $sFilePath_2 & '"', @WorkingDir, @SW_HIDE) = 0 Sleep(1000) EndFunc I will test my solutsion for some days and let's see - when it's working, how it's working... EDIT: sorry, loop is still missing, will implement it. BR, Rackoon Edited October 20, 2013 by Rackoon 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