Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2019
  • Last Modified:

auto update winforms vb.net application

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
rowternet
Asked:
rowternet
  • 6
  • 3
1 Solution
 
ozi_lionCommented:
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
 
rowternetAuthor Commented:
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
 
käµfm³d 👽Commented:
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
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 
rowternetAuthor Commented:
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
 
käµfm³d 👽Commented:
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
 
rowternetAuthor Commented:
Hi, if i have to use a savedialog box for this how can i do this?
0
 
käµfm³d 👽Commented:
>>  if i have to use a savedialog box for this how can i do this?

Use it for what?
0
 
rowternetAuthor Commented:
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
 
rowternetAuthor Commented:
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
 
rowternetAuthor Commented:
Thanks
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now