Results 1 to 9 of 9

Thread: Updating an application

  1. #1

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Question Updating an application

    If I create an update to my program and then later on my application downloads the latest version. How can I overwrite the currently running executable with the newer version? Should I create a seperate application that waits until my program is closed and then runs the installation? Is there a better way to do this?

  2. #2
    Frenzied Member conipto's Avatar
    Join Date
    Jun 2005
    Location
    Chicago
    Posts
    1,175

    Re: Updating an application

    I would go the route of an "updater" program. You could make a flag that is checked when the application exits, and if it knows it has a new version to update, launch that program on exit, and overwrite the file.

    Bill
    Hate Adobe Acrobat? My Codebank Sumbissions - Easy CodeDom Expression evaluator: (VB / C# ) -- C# Scrolling Text Display

    I Like to code when drunk. Don't say you weren't warned.

  3. #3
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: Updating an application

    actually the way i have done it is this:

    make a web service where the application can download the latest version.

    Once done, it downloads it to the working directory of the application.

    THEN all I would do, is update the shortcut on the start menu to point to the NEW version of the application.

    thats all!

    if you wish to delete the application after a new application version has been downloaded, then simply, at startup, check for any existing application in the program directory/running directory and check the version numbers ... remove them as necessary!

    thats the way i did it for my PC server and mobile client application works very well

  4. #4
    Frenzied Member Phill64's Avatar
    Join Date
    Jul 2005
    Location
    Queensland, Australia
    Posts
    1,201

    Re: Updating an application

    i never thought of that, clever idea, alternating exe names.. although no good if the user has made their own shortcuts.

    I am needing to do this shortly and i was going to approach it this way
    [1st instance]
    download new exe from server
    save file as temp.exe
    execute temp.exe (no wait)
    terminate
    [/end 1st instance]
    [2nd instance]
    delete original.exe
    copy self as original.exe
    execute original.exe (no wait)
    terminate
    [/end 2nd instance]
    [3rd instance]
    delete temp.exe
    continue running as normal
    [/end 3rd instance]

  5. #5
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476

    Re: Updating an application

    In Visual Studio 2005 using the .NET Framework 2.0 there is an Application called ClickOnce. You can use it to deploy your application and it also contains an Updater Functionality.

    Check this link to see if it fits your needs:

    http://msdn.microsoft.com/smartclien...clickonce.aspx

    Heres the FAQ for ClickOnce:

    http://www.windowsforms.net/FAQs/def...=24&tabindex=2

    HTH,

    Stephan
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

  6. #6

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Updating an application

    Thanks but I'm using .Net 1.1 so it has a larger user base (for now).

    I think I'll create a seperate updating application that waits for exit on my main app and then replace the exe. I need to extra the contents from a zip so I'll have to figure that one out

  7. #7
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476

    Re: Updating an application

    For zip in .NET 1.1 i always use the Sharp Zip Lib. Lacks some features but its quite easy to use if all you want to do is zip files or extract Files from a zip.
    Its free and Open Source.
    Heres a link for you.

    http://www.icsharpcode.net/OpenSourc.../Download.aspx


    HTH,

    Stephan
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

  8. #8
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Updating an application

    Check out the Microsoft Updater Application Block.

    http://www.microsoft.com/downloads/d...displaylang=en

  9. #9
    New Member
    Join Date
    Dec 2005
    Location
    United States
    Posts
    7

    Re: Updating an application

    I've done it a few ways in the past. With a seperate updater program. Downloading the new updates, then using the updater program to restart my application, before it restarts the application delete the old exe and rename the new one.

    1. Launch Updater Program
    2. Download Updates
    3. Shutdown Application
    4. Rename Files
    5. Start Application
    6. Shutdown Updater Program


    I've also went as far as creating a bat file, saving it in the startup directory and then restarting the computer, but in your case that might be a little too much.
    - Billiard
    If you would like me to read your code, please use [code] tags.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width