Solved

auto update winforms vb.net application

Posted on 2010-08-29
10
1,808 Views
Last Modified: 2012-05-10
Hi,

I ma working with a winforms application. Every time i create a new uild, insted of going and installing on each pc is there any way i can update automatically?
I will post a build on a web site an the application should check the website upon each new login if there is aa new version.
If a new version exists, it sould update else cntinue with the current update.

Is it possible? I am using setup  and deployment process. I do not want to use click once deployment process.


Thanks.
0
Comment
Question by:rowternet
  • 6
  • 3
10 Comments
 
LVL 2

Expert Comment

by:ozi_lion
ID: 33552302
Hi, It is possible to do that by several ways. Yiu can compare version numbers of current application version number and new one if different it is an update. Also you can put a text file contains an update informations like if file contains 1 there is an update or if 0 there is no new update. you can check new version onload or in some periods or let your client to choose when they want to check for update. best way i think put a small file contains new version information to your ftp and let your client application to read this file and compare with current version installed. if number in file is bigger than installed one then you can download and install update program.

hope it helps. i am doing this with VB6 using inet and works great.


0
 

Author Comment

by:rowternet
ID: 33556362
So far this i what i have:
I do not have the site where i upload my project. I have to finish the rest tomorrow.



 Private Sub getsourcecode()
        Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("http://www.mysite.com/Information/myMgrVersion/myMgrVersion.htm")
        Dim response As System.Net.HttpWebResponse = request.GetResponse
        Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream)
        Dim newerversion As String = sr.ReadToEnd
        Dim currentversion As String = Application.ProductVersion
        If newerversion.Contains(currentversion) Then
            MessageBox.Show("No new version")
        Else
            MessageBox.Show("Newer version is available")
        End If
    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        getsourcecode()

    End Sub
    Private Sub downloadfile()
        Dim client As New Net.WebClient
        client.DownloadFile("www.mysite.com/Information/Tr", "Sr.exe")


    End Sub
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 33556384
You're not going to be able to update the application while it's in memory, so in my estimate you are going to need to create a separate .exe which your main app launches. This app would check for the update and if found, kill the main app, get the update, and then relaunch the main app once the file has been downloaded and installed. You need to settle on how you determine whether a new version is available, but it appears you have that covered.  :)
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:rowternet
ID: 33562041
kaufmed and ozlion,

How do i kill the main app if a new version is detected ? and how do i install the new one when the current version is running?

Can you provde code or any links which explain this process?

Thanks.
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 33562988
You would have code in your main app that would launch the update app (Example 1). If the update app detects a new version, it would loop through the running processes and kill all main app instances (Example 2). In Example 2, "WindowsFormsApplication.vshost" is the name of the process (less the ".exe") that is acting as my main app. You would of course substitute in your application name there.
/// <summary>
/// Example 1
/// </summary>
/// <remarks>
/// This is in your main app
/// </remarks>
public void CheckForUpdates()
{
    System.Diagnostics.Process.Start(@"C:\path\to\your\update\app.exe");
}

/// <summary>
/// Example 2
/// </summary>
/// <remarks>
/// This is in your update app
/// </remarks>
public void KillAppInstances()
{
    foreach (var proc in System.Diagnostics.Process.GetProcessesByName("WindowsFormsApplication2.vshost"))
    {
        proc.Kill();
    }
}

Open in new window

0
 

Author Comment

by:rowternet
ID: 33563978
Hi, if i have to use a savedialog box for this how can i do this?
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 33576341
>>  if i have to use a savedialog box for this how can i do this?

Use it for what?
0
 

Author Comment

by:rowternet
ID: 33802175
Hi Kaufmed,
I am almost done with the code for auto updating.
when i try to kill the process, using what you gave earlier,

  For Each proc As var In System.Diagnostics.Process.GetProcessesByName("")
            proc.Kill()
        Next

I am geting a error : Type 'var' isnot defined.
why am i getting this error?

thanks
0
 

Author Comment

by:rowternet
ID: 33809078
Dont worry. I have it working this way
Private Shared Sub killApp()
        'MessageBox.Show("Killing Started")
        Dim myprocess() As Process
        Dim proc As Process
        myprocess = Process.GetProcesses
        Dim mystring As String = Nothing
        Dim myprocstring As String = Nothing
       
        myprocstring = "System.Diagnostics.Process (ShahTransportationMgrProject)"
        'MessageBox.Show(myprocstring.Length)
        Try
            For Each proc In myprocess
                mystring = proc.ToString
                Dim abc As Integer = mystring.CompareTo(myprocstring)
                If abc = 0 Then
                    proc.Kill()
                End If
            Next
        Catch ex As Exception
            MessageBox.Show(ex.ToString, "Warning: Killing Started")
        End Try

    End Sub

Open in new window

0
 

Author Closing Comment

by:rowternet
ID: 33809099
Thanks
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How do I prevent the pages in my site from showing up in a google search? 2 74
Not seen Link button 5 37
Disable extension 8 37
Expression Evaluater 3 24
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question