Sign in to follow this  
Followers 0
10031992

Help updater programs

5 posts in this topic

[English]

I'm trying to make an updater for my program, but I'm trying a problem that I can not find a result to solve them.

After upgrading it, it opens a "Msgbox" warning that the upgrade is seucesso, and soon after the program opens normally, the problem that I am not able to do with the Program.exe that is already running is "paused "and" Rename "to the other. exe that just arrived for the download may be in the same folder in order not to name clashes, and after the new program.exe arrive, the former should be" deleted "or" substituted "so it can open again ".exe" updated

[Portuguese]

Estou tentando fazer um atualizador para meu programa, porem estou tento um problema que nao consigo achar um resultado para resolvelo.

Após ele fazer a atualização, abre uma "Msgbox" avisando que a atualização foi feita com seucesso, e logo em seguida o programa abre normalmente, o problema que não estou conseguindo fazer, com que o Program.exe que já está sendo executado seja "pausado" e "renomeiado" para que o outro .exe que acaba de chegar pelo download possa ficar na mesma pasta para não dar conflitos entre nomes, e depois que o novo program.exe chegar, o antigo deve ser "deletado" ou "substituido" para que possa abrir o novo .exe

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ProgressConstants.au3>
#include <EditConstants.au3>
#include <Inet.au3>
; Fim Dos Includes E #


_Update("http://127.0.0.1:8888/Ver.txt", 1.2, "- GOHC", "http://rgtclan.com")

Func _Update($Vercao_Servidor,$Vercao_Client,$sPrograma,$sProgramaURL,$hParent="")
    Local $Ver_Anterior = BinaryToString(InetRead($Vercao_Servidor,1))
    If StringLeft($Ver_Anterior, 8) = "Version=" Then
        $Ver_Anterior = StringTrimLeft($Ver_Anterior, 8)
        If $Ver_Anterior <> $Vercao_Client Then
           If MsgBox(4,$sPrograma, "Um nova versao." & "(V" & $Ver_Anterior & ") gostaria " & $sPrograma & " website to download it?",default,$hParent) = 6 Then Form3()

         EndIf
     EndIf
EndFunc
; Fim Da Verificação

_open()


; Form 3
Func Form3()
$Form3 = GUICreate("Atualizador", 315, 212, -1, -1, -1, $WS_EX_TOOLWINDOW)
$Group1 = GUICtrlCreateGroup("Progressos", 8, 8, 297, 193, BitOR($BS_CENTER,$BS_FLAT))
$Group2 = GUICtrlCreateGroup("Download", 16, 24, 281, 81, $BS_FLAT)
$Progress1 = GUICtrlCreateProgress(24, 48, 265, 17)
$Label1 = GUICtrlCreateLabel("Porcentagem De Download: 0%", 24, 76, 265, 17, BitOR($SS_CENTER,$WS_BORDER))
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
$Link_Download = "http://127.0.0.1:8888/program.exe"
For $Download = 1 To 100 Step 10
GUICtrlSetData($Progress1, $Download)
GUICtrlSetData($Label1, "Porcentagem De Download: " & $Download & "%")
InetGet($Link_Download, "program.exe", 1)
Next
GUICtrlSetData($Label1, "Download Concluido Com Sucesso")
  If MsgBox(0,"Abrir o Software?","Programa Atualizado",1000,Default) = 6  Then _open()

EndFunc



_open() ; open program
Func _open()
MsgBox(0,"Program open","program to be open")

Summary:

check version, pause the program, rename the program after downloading and delete the old program and restart, opening the new program updated

Thnx all


-------------------------------------------------------------------------------------------------------------------------------------------- [center][/center][center]Autoit Support Forum in Portuguese | AutoitBrasil.com[/center] [sub]My Script :[/sub]Simples Login for Program

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

; IMPORTANT MAKE A COPY OF SCRIPT BEFORE DELETION
; Deletes the running script renames downloaded and starts New named Program
; Author MHz edited by rogue5099

If @Compiled Then _SelfDeleteUpdate()

Func _SelfDeleteUpdate($iDelay = 0)
    Local $sCmdFile
    FileDelete(@TempDir & "\scratch.bat")
    $sCmdFile = 'ping -n ' & $iDelay & '127.0.0.1 > nul' & @CRLF _
            & ':loop' & @CRLF _
            & 'del "' & @ScriptFullPath & '"' & @CRLF _
            & 'if exist "' & @ScriptFullPath & '" goto loop' & @CRLF _
            & 'ren "' & @ScriptDir & '\Downloaded.exe" ' & '"' & @ScriptDir & '\NewName.exe"' & @CRLF _
            & 'run "' & @ScriptDir & '\NewName.exe"' & @CRLF _
            & 'del ' & @TempDir & '\scratch.bat'
    FileWrite(@TempDir & "\scratch.bat", $sCmdFile)
    Run(@TempDir & "\scratch.bat", @TempDir, @SW_HIDE)
    Exit
EndFunc

Edited by rogue5099

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Do not get it right, the "Program.exe" that is running will be updated and can not be with the same name, which is downloading, but why he did not he delete them? the 2

Or what is downloading (the update), use a different name and after he finished(downloading), and are in the folder will change its name to the name of the previous program was deleted?

take a look

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ProgressConstants.au3>
#include <EditConstants.au3>
#include <Inet.au3>

_Update("http://127.0.0.1:8888/Ver.txt", 1.0, "- GOHC", "http://rgtclan.com")

Func _Update($Vercao_Servidor,$Vercao_Client,$sPrograma,$sProgramaURL,$hParent="")
    Local $Ver_Anterior = BinaryToString(InetRead($Vercao_Servidor,1))
    If StringLeft($Ver_Anterior, 8) = "Version=" Then
        $Ver_Anterior = StringTrimLeft($Ver_Anterior, 8)
        If $Ver_Anterior <> $Vercao_Client Then
           If MsgBox(4,$sPrograma, "Um nova versao." & "(V" & $Ver_Anterior & ") gostaria " & $sPrograma & " website to download it?",default,$hParent) = 6 Then Form3()

         EndIf
     EndIf
EndFunc
; Fim Da Verificação

_open()





; Form 3
Func Form3()
$Form3 = GUICreate("Atualizador", 315, 212, -1, -1, -1, $WS_EX_TOOLWINDOW)
$Group1 = GUICtrlCreateGroup("Progressos", 8, 8, 297, 193, BitOR($BS_CENTER,$BS_FLAT))
$Group2 = GUICtrlCreateGroup("Download", 16, 24, 281, 81, $BS_FLAT)
$Progress1 = GUICtrlCreateProgress(24, 48, 265, 17)
$Label1 = GUICtrlCreateLabel("Porcentagem De Download: 0%", 24, 76, 265, 17, BitOR($SS_CENTER,$WS_BORDER))
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
$Link_Download = "http://127.0.0.1:8888/update.exe" ; update program
For $Download = 1 To 100 Step 10
GUICtrlSetData($Progress1, $Download)
GUICtrlSetData($Label1, "Porcentagem De Download: " & $Download & "%")
InetGet($Link_Download, "update.exe", 1)
Next
GUICtrlSetData($Label1, "Download Complet Sucess")
  If @Compiled Then _SelfDeleteUpdate() ; your
EndFunc



Func _SelfDeleteUpdate($iDelay = 0)
    Local $sCmdFile
    FileDelete(@TempDir & "\scratch.bat")
    $sCmdFile = 'ping -n ' & $iDelay & '127.0.0.1:8888 > nul' & @CRLF _
            & ':loop' & @CRLF _
            & 'del "' & @ScriptFullPath & '"' & @CRLF _
            & 'if exist "' & @ScriptFullPath & '" goto loop' & @CRLF _
            & 'ren "' & @ScriptDir & '\update.exe" ' & '"' & @ScriptDir & '\Program.exe"' & @CRLF _ ; different name
            & 'run "' & @ScriptDir & '\Program.exe"' & @CRLF _
            & 'del ' & @TempDir & '\scratch.bat'
    FileWrite(@TempDir & "\scratch.bat", $sCmdFile)
    Run(@TempDir & "\scratch.bat", @TempDir, @SW_HIDE)
    Exit
EndFunc

I'm having doubts about it, if. "exe" which will download, you have to be with the same name or different name, but then he is deleting the two executables

Edited by 10031992

-------------------------------------------------------------------------------------------------------------------------------------------- [center][/center][center]Autoit Support Forum in Portuguese | AutoitBrasil.com[/center] [sub]My Script :[/sub]Simples Login for Program

Share this post


Link to post
Share on other sites

What this does is creates a .bat file then runs the .bat file. Inside the .bat file is the following:

& ':loop' & @CRLF _ ****STARTS A LOOP TO MAKE SURE FILE IS DELETED****

& 'del "' & @ScriptFullPath & '"' & @CRLF _ ****TRYS TO DELETE****

& 'if exist "' & @ScriptFullPath & '" goto loop' & @CRLF _ ****IF NOT DELETED THEN GO BACK TO LOOP TO TRY TO DELETE****

& 'ren "' & @ScriptDir & '\update.exe" ' & '"' & @ScriptDir & '\Program.exe"' & @CRLF _ ; different name ****RENAMES UPDATE.EXE****

& 'run "' & @ScriptDir & '\Program.exe"' & @CRLF _****RESTARTS NEWLY RENAMED UPDATE.EXE****

& 'del ' & @TempDir & '\scratch.bat' ****DELETES THIS BAT FILE****

Maybe add more delays so it has time to recognize the newly renamed file?

****Someone else please check if I added these lines correctly I'm not seeing anything at the moment....

Share this post


Link to post
Share on other sites

Let's see if somebody else sees

and stay in the waiting


-------------------------------------------------------------------------------------------------------------------------------------------- [center][/center][center]Autoit Support Forum in Portuguese | AutoitBrasil.com[/center] [sub]My Script :[/sub]Simples Login for Program

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0