Jump to content

I Cant Seem To Work This...


evilelf
 Share

Recommended Posts

I Fould This Scrip On The Forms,

But Cant Seem To Get It To Work Right.

I Cant Seem To Have The Program Update

If the Version Its running Is Lower Then The One

In The .ini

$auto = 1
If $CmdLine[0] > 0 Then
    If $CmdLine[1] = "DoNotAutoStart" Then $auto = 0
EndIf
Local $ping = Ping("www.Google.com");Website to ping to check if internet access is available
Local $Website = "MySite.exe"
Local $myini = "MySite"
$retry = 0
While 1
    If $ping = 0 Then
        $retry = MsgBox(5, "MyProgram - Update", "Error! Please connect to the Internet and try again!")
    EndIf
    If $retry = 4 Then
        Local $ping = Ping("www.Google.com")
    EndIf
    If $retry = 2 Then
        Exit
    EndIf
    If $ping <> 0 Then ExitLoop
WEnd
If $ping <> 0 Then
    InetGet($myini,"C:\update.ini", 1)
    If IniRead("C:\update.ini", "Update", "FileVer", "0.0.0.0") > FileGetVersion("MyProgram.exe") Then
        $msgA = MsgBox(4, "Update", "MyProgram " & IniRead("C:\update.ini", "Update", "FileVerDescript", "Not Found") & " is available, Update now?")
        If $msgA = 6 Then
            ProcessClose("MyProgram.exe")
            FileMove(@ScriptDir & "\MyProgram.exe", @ScriptDir & "\MyProgram.bak.exe", 1)
            InetGet($Website, @ScriptDir & "\MyProgram.exe", 1, 1)
            ProgressOn("Downloading Update", "Downloading", "", -1, -1, 16)
            While @InetGetActive
                $downloaded = (@InetGetBytesRead / IniRead("C:\Update.ini", "Size", "Bytes", 0) * 100)
                $downloaded = Int($downloaded)
                ProgressSet($downloaded)
            WEnd
            ProgressOff()
            $updatecheck = FileExists(@ScriptDir & "\Ecto_V2.exe")
            $exesize = FileGetSize(@ScriptDir & "\Ecto_V2.exe")
            If $updatecheck = 1 And $exesize = IniRead("C:\Update.ini", "Size", "Bytes", 0) Then
                MsgBox(0, "Complete", "MyProgram has been updated to: " & IniRead("C:\Update.ini", "Update", "FileVerDescript", "Not Found"))
                FileDelete(@ScriptDir & "\MyProgramOld.bak.exe")
                If $auto = 1 Then
                    MsgBox(0, "Running Myprogram", "Update will now run MyProgram", 2)
                    Run(@ScriptDir & "\MyProgram.exe")
                EndIf
            EndIf
            If $updatecheck = 0 Or $exesize <> IniRead("C:\Update.ini", "Size", "Bytes", 0) Then
                FileMove(@ScriptDir & "\MyProgramOld.bak.exe", @ScriptDir & "\MyProgram.exe", 1)
                MsgBox(48, "Error!", "The download failed, either the file wasn't downladed or file was corrupt - Updater has restored your previous Ecto_V2 file")
            EndIf
        EndIf
        FileDelete("C:\Update.ini")
        Exit
    EndIf
    If IniRead("C:\Update.ini", "Update", "FileVer", "0.0.0.0.") <= FileGetVersion("MyProgram.exe") Then
        MsgBox(0, "Latest", "You currently have the latest version of MyProgram")
        FileDelete("C:\Update.ini")
    EndIf
EndIf
Link to comment
Share on other sites

  • Moderators

Type regularly. There is absolutely no need to capitalize every word... It actually has made me not even get past the first sentence you wrote other than to see if you did it throughout the entire post.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Type regularly. There is absolutely no need to capitalize every word... It actually has made me not even get past the first sentence you wrote other than to see if you did it throughout the entire post.

Smoke...

You have been nice in the past,..But man WoW...

If Its that hard to read Then NvM,

I'll Fix it on My Own.

Dont take this the Wrong Way,..

Ruff Week and from 3-7am

Was very Bad For Me...

Thanks For The...Help,

Ill just fix it...

Link to comment
Share on other sites

  • Developers

... looks like you didn't read/understand what was said.

as to your issue:

Debug it by showing what the content is of the functions you use to retrieve the Ini info and the program fileversion.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Type regularly. There is absolutely no need to capitalize every word... It actually has made me not even get past the first sentence you wrote other than to see if you did it throughout the entire post.

It actually hurts my eyes to read the sentences/words/mubo jumbo...
Link to comment
Share on other sites

... looks like you didn't read/understand what was said.

as to your issue:

Debug it by showing what the content is of the functions you use to retrieve the Ini info and the program fileversion.

Jos

I was trying 2 do that,

But I

Lost a lot of sleep and could not toy around with it much longer.

-Thanks, I'll toy around with this when-ever I have time this week.

It actually hurts my eyes to read the sentences/words/mubo jumbo...

I Forget Monkey see monkey do...

- Maybe you should get out side more and stop sitting infont

of the computer if your eyes hurt that bad...

*Just A Thought*

I love how people post random dumb replys

for there post count...

Edited by evilelf
Link to comment
Share on other sites

I get outside enough- I work part time, I cycle, I like to go out in my mates boat (see avatar...). I spend the rest of my time either playing my instrument, at school, asleep or on here. More than enough to keep me busy.

I'm having a look now, to see if I can work it out.

Seemed to work okay for what you've given us.

#Include <Misc.au3>
;Make the INI,
IniWrite ("C:\update.ini", "Update", "FileVer", "0.0.0.0")
;Start script
$auto = 1
If $CmdLine[0] > 0 Then
    If $CmdLine[1] = "DoNotAutoStart" Then $auto = 0
EndIf

Local $ping = Ping("www.Google.com");Website to ping to check if internet access is available
Local $Website = "MySite.exe"
Local $myini = "MySite"
$retry = 0

While 1
    If $ping = 0 Then
        $retry = MsgBox(5, "MyProgram - Update", "Error! Please connect to the Internet and try again!")
    EndIf
    If $retry = 4 Then
        Local $ping = Ping("www.Google.com")
    EndIf
    If $retry = 2 Then
        Exit
    EndIf
    If $ping <> 0 Then ExitLoop
WEnd

If $ping <> 0 Then
    InetGet($myini,"C:\update.ini", 1)
   ;If _VersionCompare (IniRead("C:\update.ini", "Update", "FileVer", "0.0.0.0"), FileGetVersion("MyProgram.exe")) Then
    If _VersionCompare (IniRead("C:\update.ini", "Update", "FileVer", "0.0.0.0"), "0.0.0.1") = 1 Then
        $msgA = MsgBox(4, "Update", "MyProgram " & IniRead("C:\update.ini", "Update", "FileVerDescript", "Not Found") & " is available, Update now?")
        If $msgA = 6 Then
            ProcessClose("MyProgram.exe")
            FileMove(@ScriptDir & "\MyProgram.exe", @ScriptDir & "\MyProgram.bak.exe", 1)
            InetGet($Website, @ScriptDir & "\MyProgram.exe", 1, 1)
            ProgressOn("Downloading Update", "Downloading", "", -1, -1, 16)
            While @InetGetActive
                $downloaded = (@InetGetBytesRead / IniRead("C:\Update.ini", "Size", "Bytes", 0) * 100)
                $downloaded = Int($downloaded)
                ProgressSet($downloaded)
            WEnd
            ProgressOff()
            $updatecheck = FileExists(@ScriptDir & "\Ecto_V2.exe")
            $exesize = FileGetSize(@ScriptDir & "\Ecto_V2.exe")
            If $updatecheck = 1 And $exesize = IniRead("C:\Update.ini", "Size", "Bytes", 0) Then
                MsgBox(0, "Complete", "MyProgram has been updated to: " & IniRead("C:\Update.ini", "Update", "FileVerDescript", "Not Found"))
                FileDelete(@ScriptDir & "\MyProgramOld.bak.exe")
                If $auto = 1 Then
                    MsgBox(0, "Running Myprogram", "Update will now run MyProgram", 2)
                    Run(@ScriptDir & "\MyProgram.exe")
                EndIf
            EndIf
            If $updatecheck = 0 Or $exesize <> IniRead("C:\Update.ini", "Size", "Bytes", 0) Then
                FileMove(@ScriptDir & "\MyProgramOld.bak.exe", @ScriptDir & "\MyProgram.exe", 1)
                MsgBox(48, "Error!", "The download failed, either the file wasn't downladed or file was corrupt - Updater has restored your previous Ecto_V2 file")
            EndIf
        EndIf
        FileDelete("C:\Update.ini")
        Exit
    EndIf
    If IniRead("C:\Update.ini", "Update", "FileVer", "0.0.0.0.") <= FileGetVersion("MyProgram.exe") Then
        MsgBox(0, "Latest", "You currently have the latest version of MyProgram")
        FileDelete("C:\Update.ini")
    EndIf
EndIf

Cheers,

Brett

Edited by BrettF
Link to comment
Share on other sites

Thank You BrettF

I want 2 cycle!

If I run into a problem

I'll post in here.

Ps: I always liked the work you have did,

and... I Might steal your " _LoginBox "

cause I Like it...

Make sure you give credit where it is due, because last time I checked, stealing code was taking someones work and passing it off as your own... Not the best thing to do.

Cheers,

Brett

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...