dynty Posted March 30, 2009 Share Posted March 30, 2009 Hello, I undertsand i will be bashed badly for something or noone will reply,but i will try When i have script,compited to exe c:\x\test.exe and i want to update it by new version,lets say by function "InetGet" InetGet("http://boiians.cz/test.exe.org/", "c:\x\test.exe") is it possible to do this somehow? Make copliled script file to rewrite itself,so it will run as a "new version" next time you execute it? i have been wondering for a very long time,so i decided to ask here. Normally,i update my scripts on remote machines using another program,lets say updater.exe,but i would like to do it with one file only. Is there a way how to set file permisions or something,to allow this? How? If its solved somewhere,please,could you point me there? Thanks a lot for help Link to comment Share on other sites More sharing options...
ChrisL Posted March 30, 2009 Share Posted March 30, 2009 You could make windows copy it in on restarthttp://www.autoitscript.com/forum/index.ph...c=33669&hl= [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
Exit Posted March 30, 2009 Share Posted March 30, 2009 Hello,I undertsand i will be bashed badly for something or noone will reply,but i will try When i have script,compited to exec:\x\test.exeand i want to update it by new version,lets say by function "InetGet"InetGet("http://boiians.cz/test.exe.org/", "c:\x\test.exe")is it possible to do this somehow?Make copliled script file to rewrite itself,so it will run as a "new version" next time you execute it?i have been wondering for a very long time,so i decided to ask here.Normally,i update my scripts on remote machines using another program,lets say updater.exe,but i would like to do it with one file only.Is there a way how to set file permisions or something,to allow this?How?If its solved somewhere,please,could you point me there?Thanks a lot for help1.) Compile new version as Testnew.exe2.) Rename Test.exe to Testold.exe. Yes, rename is possible.3.) Rename Testnew.exe to Test.exe.4.) Restart Test.exe 5.) Delete Testold.exe App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
ChrisL Posted March 30, 2009 Share Posted March 30, 2009 2.) Rename Test.exe to Testold.exe. Yes, rename is possible. Are you sure about that cos this doesn't work FileMove('"' & @ScriptFullPath & '"','"' & @scriptDir & '\old.exe"',1) [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
dynty Posted March 30, 2009 Author Share Posted March 30, 2009 1.) Compile new version as Testnew.exe2.) Rename Test.exe to Testold.exe. Yes, rename is possible.3.) Rename Testnew.exe to Test.exe.4.) Restart Test.exe 5.) Delete Testold.exedo you use some UDF for that "rename" ? filemove does not work for mefor example this,FileMove("c:\a\test.exe", "c:\a\test2.exe")does not work if "test.exe" is copiled .exe with only "FileMove("c:\a\test.exe", "c:\a\test2.exe")" in it.run test.exe and it is trying to rename itself - and it will fail because this process is already running.I was wondering if there was an solution how to do this,ChrisL pointed good udf that can update that script at reboot,but it still cannot make file rename itself (you use external "application" for that) Link to comment Share on other sites More sharing options...
ChrisL Posted March 30, 2009 Share Posted March 30, 2009 Msgbox(0,"","Start") _UpdateMe("NewFile.exe") Func _UpdateMe ($newFile) Local $sCmdFile, $iDelay=1 If NOT FileExists(@scriptDir & '\' & $newFile) then Return SetError(1) FileDelete(@TempDir & "\scratch.bat") FileDelete(@ScriptFullPath & ".old") $sCmdFile = 'ping -n ' & $iDelay & '127.0.0.1 > nul' & @CRLF _ & ':loop' & @CRLF _ & 'Rename "' & @ScriptFullPath & '" "' & @ScriptName & '.old"' & @CRLF _ & 'if exist "' & @ScriptFullPath & '" goto loop' & @CRLF _ & 'Rename "' & @ScriptDir & '\' & $newFile & '" "' & @ScriptName & '"' & @CRLF _ & '"' & @ScriptFullPath & '"' & @CRLF _ & 'del "' & @ScriptFullPath & '.old"' & @CRLF _ & 'del ' & @TempDir & '\scratch.bat' FileWrite(@TempDir & "\scratch.bat", $sCmdFile) Run(@TempDir & "\scratch.bat", @TempDir, @SW_HIDE) Exit EndFunc [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
Exit Posted March 30, 2009 Share Posted March 30, 2009 Try my code. It works for me. ;-) __SingleScript() ; kill previous process $Time = FileGetTime(@ScriptFullPath, 1, 1) FileDelete(@ScriptFullPath & ".Old") FileMove(@ScriptFullPath, @ScriptFullPath & ".Old", 1) MsgBox(0, 'Remember the creation time', $Time) While Sleep(1000) ; keep the process alive WEnd Func __SingleScript() Local $O = ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2") Local $OI, $CI = $O.ExecQuery("SELECT * FROM Win32_Process", "WQL", 0x30) For $OI In $CI If $OI.ProcessId = @AutoItPID Then ContinueLoop If $OI.Name = StringTrimRight(@ScriptName, 4) & ".EXE" Then ProcessClose($OI.ProcessId) If $OI.Name = "AutoIt3.exe" And StringInStr($OI.CommandLine, StringTrimRight(@ScriptName, 4) & ".au3") Then ProcessClose($OI.ProcessId) Next EndFunc ;==>__SingleScript App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
silvano Posted March 30, 2009 Share Posted March 30, 2009 sorry.. but filecopy work fine... in the test.exe: FileCopy("c:\a\test.exe", "c:\a\test2.exe") 1.) Compile new version as test2.exe 2) exit and run test2.exe 3.) delete Test.exe 4.) copy test2.exe to test.exe 5 ) exit and run test.exe 6.) Delete test2.exe 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