Solved

auto update winforms vb.net application

Posted on 2010-08-29
10
1,859 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

734 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