(last product version)|(lastest version doanload link)|(optional: changelogs, putting a "/" equals to a new line)
Class Updater
Private DownloadLink As String = String.Empty
Private Bar As New ProgressBar With {.Location = New Point(10, 180), .Height = 15, .Width = 320}
#Region "Forms"
Delegate Sub ChangeFormStatus(ByVal F As Form, ByVal Var As Boolean)
Sub ChangeStatus(ByVal Var As Boolean)
For Each F As Form In My.Application.OpenForms
F.Invoke(New ChangeFormStatus(AddressOf SingleFormChange), New Object() {F, Var})
Next
End Sub
Sub SingleFormChange(ByVal F As Form, ByVal Var As Boolean)
If Var Then
F.Show()
Else
F.Hide()
End If
End Sub
#End Region
Sub New(ByVal Link As String, ByVal ForceUpdate As Boolean)
Dim T As New Threading.Thread(Sub() CheckUpdates(Link, ForceUpdate))
T.Start()
End Sub
Sub CheckUpdates(ByVal Link As String, ByVal ForceUpdate As Boolean)
ChangeStatus(False)
If Not System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable() Then : Exit Sub : End If
Dim Version = String.Empty, Changelog As String = String.Empty
Dim resp As String = New Net.WebClient().DownloadString(Link)
Version = resp.Split("|")(0)
DownloadLink = resp.Split("|")(1)
If CountOccurance(resp, "|", True) > 1 Then : Changelog = resp.Split("|")(2) : End If
If Version = Application.ProductVersion.ToString Then
ChangeStatus(True)
Else
If ForceUpdate Then
CreateForm(Changelog)
Else
Select Case MessageBox.Show("A new updated version is available, would you like to update now?", "Update Available", MessageBoxButtons.YesNoCancel)
Case DialogResult.Yes
CreateForm(Changelog)
Case DialogResult.No
ChangeStatus(True)
Case DialogResult.Cancel
End
End Select
End If
End If
End Sub
Function CountOccurance(ByVal Data As String, ByVal Search As String, Optional ByVal CaseSensitive As Boolean = False) As Integer
'credits to idb
Return (IIf(CaseSensitive, (Data.Length - (Data.Replace(Search, "").Length)), (Data.Length - (Data.ToLower.Replace(Search.ToLower, "").Length))) / Search.Length)
End Function
#Region "Form Processes"
Private Sub CreateForm(ByVal Changelog As String)
Dim Frm As New Form With {.Size = New Size(350, 240), .Text = "Updating...", .StartPosition = FormStartPosition.CenterScreen, .FormBorderStyle = FormBorderStyle.FixedDialog}
Frm.Controls.Add(New Label With {.Text = "The process will take few seconds...", .Location = New Point(10, 20), .Width = 270})
Frm.Controls.Add(New Label With {.Text = "Changelogs:", .Location = New Point(10, 43), .Width = 100, .Height = 15})
Frm.Controls.Add(New TextBox With {.Multiline = True, .ScrollBars = ScrollBars.Vertical, .Location = New Point(10, 65), .Height = 100, .Width = 320, .Enabled = False, .Text = IIf(String.IsNullOrWhiteSpace(Changelog), Nothing, Changelog.Replace("/", vbNewLine))})
Frm.Controls.Add(Bar)
AddHandler Frm.Load, AddressOf LoadDownloadForm
AddHandler Frm.FormClosing, AddressOf FormClosing
Application.Run(Frm)
End Sub
Private Sub LoadDownloadForm()
Dim w As New Net.WebClient
AddHandler w.DownloadProgressChanged, AddressOf ProgressChanged
AddHandler w.DownloadFileCompleted, AddressOf DownloadCompleted
w.DownloadFileAsync(New Uri(DownloadLink), Application.StartupPath & "\" & IO.Path.GetFileNameWithoutExtension(Application.ExecutablePath) & "Updated.exe")
End Sub
Private Sub ProgressChanged(ByVal sender As Object, ByVal e As Net.DownloadProgressChangedEventArgs)
Dim bytesScaricati As Double = Double.Parse(e.BytesReceived.ToString())
Dim bytesTotali As Double = Double.Parse(e.TotalBytesToReceive.ToString())
Dim percentage As Double = (bytesScaricati / bytesTotali * 100)
Bar.Value = Int32.Parse(Math.Truncate(percentage).ToString())
End Sub
Private Sub DownloadCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs)
Process.Start(Application.StartupPath & "\" & IO.Path.GetFileNameWithoutExtension(Application.ExecutablePath) & "Updated.exe")
Dim Close As New ProcessStartInfo With {.FileName = "cmd.exe", .WindowStyle = ProcessWindowStyle.Hidden}
Close.Arguments = "/C ping 1.1.1.1 -n 1 -w 2000 > Nul & Del """ & Application.ExecutablePath & """"
Process.Start(Close)
End
End Sub
Private Sub FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs)
e.Cancel = True
End Sub
#End Region
End Class
Copyright © 2026, NextGenUpdate.
All Rights Reserved.