Jump to content

AutoUpdate Help


Recommended Posts

Hi, im working on an autoupdater for my program... And when i run it, nothing happens :o Heres my code:

Program Itself(MAMBoT.exe):

Local $verini = 'http://acguild.ampedhost.com/bot/ver/ver.ini'
Local $ping = ping ('www.google.com', 250)

Select
Case $ping = 0
$msg1 = MsgBox(1, "Error", "No internet connection detected. Close program now?")
If $msg1 = 1 Then
Exit
EndIf
Case $ping = 1
InetGet($verini, "\Data\ver.ini", 1)
If IniRead(@ScriptDir & '\Data\ver.ini','Version','FileVer','Not Found') > IniRead(@ScriptDir & '\Data\version.ini','Version','FileVer','Not Found') Then
SplashOff()
SplashTextOn("MAMBoT", "A newer version has been found and is updating!  Please wait, the program will now restart...")
Sleep(2500)
SplashOff()
Run ('update.exe', @ScriptDir)
Exit
Else
FileDelete(@ScriptDir & '\Data\temp.ini')
EndIf
EndSelect

Updater(update.exe):

ProcessClose("MAMBoT.exe")

$newestver = IniRead(@ScriptDir '\Data\ver.ini','Version','FileVer','Not Found')
$website = 'http://acguild.ampedhost.com/bot/' & $newestver & '/MAMBoT.exe'
If FileExists(@ScriptDir & '\MAMBoT.exe') Then
FileDelete(@ScriptDir & '\MAMBoT.exe')
Else
Sleep(10)
INetGet($website, "MAMBoT.exe", 1)
IniWrite(@ScriptDir & '\Data\version.ini','Version','FileVer', $newestver)
FileDelete(@ScriptDir & '\Data\ver.ini')
Sleep(10)
SplashTextOn("MAMBoT Updater", "Successfully updated to the latest version."
Sleep(5000)
Run ('update.exe', @ScriptDir)
Exit

Do you guys see any problems? Thanks for the help in advance :geek:

Edited by jackyyll
Link to comment
Share on other sites

a quick look

$newestver = IniRead(@ScriptDir '\Data\ver.ini','Version','FileVer','Not Found')

should be

$newestver = IniRead(@ScriptDir & '\Data\ver.ini','Version','FileVer','Not Found')

edit: i don't see any endif are you using scite?

Edited by pecloe
Link to comment
Share on other sites

Changed my code to this and still no cigar:

Main Program(MAMBoT.exe)

Local $verini = 'http://acguild.ampedhost.com/bot/ver/ver.ini'
Local $ping = ping ('www.google.com', 250)

If $ping = 0 Then
$msg1 = MsgBox(1, "Error", "No internet connection detected. Close program now?")
If $msg1 = 1 Then
Exit
EndIf
EndIf
If $ping = 1 Then
InetGet($verini, "\Data\ver.ini", 1)
If IniRead(@ScriptDir & '\Data\ver.ini','Version','FileVer','Not Found') > IniRead(@ScriptDir & '\Data\version.ini','Version','FileVer','Not Found') Then
SplashOff()
SplashTextOn("MAMBoT", "A newer version has been found and is updating!  Please wait, the program will now restart...")
Sleep(2500)
SplashOff()
Run ('update.exe', @ScriptDir)
Exit
Else
FileDelete(@ScriptDir & '\Data\ver.ini')
EndIf
EndIf

Updater(update.exe):

ProcessClose("MAMBoT.exe")

$newestver = IniRead(@ScriptDir & '\Data\ver.ini','Version','FileVer','Not Found')
$website = 'http://acguild.ampedhost.com/bot/' & $newestver & '/MAMBoT.exe'
If FileExists(@ScriptDir & '\MAMBoT.exe') Then
FileDelete(@ScriptDir & '\MAMBoT.exe')
Else
Sleep(10)
INetGet($website, "MAMBoT.exe", 1)
IniWrite(@ScriptDir & '\Data\version.ini','Version','FileVer', $newestver)
FileDelete(@ScriptDir & '\Data\ver.ini')
Sleep(10)
SplashTextOn("MAMBoT Updater", "Successfully updated to the latest version."
Sleep(5000)
Run ('MAMBoT.exe', @ScriptDir)
EndIf
Exit

Can someone please help me out? :o

Link to comment
Share on other sites

Ok, try this:

Local $verini = 'http://acguild.ampedhost.com/bot/ver/ver.ini'
Local $ping = ping ('www.google.com', 250)
If $ping = 0 Then
    $msg1 = MsgBox(1, "Error", "No internet connection detected. Close program now?")
    If $msg1 = 1 Then
        Exit
    EndIf
EndIf
ConsoleWrite("Ping: " & $ping)
If $ping > 0 Then
    InetGet($verini, @ScriptDir & "\Data\ver.ini", 1)
    If IniRead(@ScriptDir & '\Data\ver.ini','Version','FileVer','Not Found') > IniRead(@ScriptDir & '\Data\version.ini','Version','FileVer','Not Found') Then
        SplashOff()
        SplashTextOn("MAMBoT", "A newer version has been found and is updating!  Please wait, the program will now restart...")
        Sleep(2500)
        SplashOff()
        Run ('update.exe', @ScriptDir)
        Exit
    Else
        FileDelete(@ScriptDir & '\Data\ver.ini')
    EndIf
EndIf

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...