Heres some code to make a simple updating system using command line parameters 😉
Create a new project then add the below code to your main forms load event.
VB .Net
C#
WAIT BUT HOW DOES THIS WORK?!...
It's simple, you get your application to download the new exe to the SAME directory your applications currently in.
Then you get your application to start the new exe with the code below.
the new exe will then close and delete the old one.
VB .Net
C#
Create a new project then add the below code to your main forms load event.
VB .Net
Code
If Environment.GetCommandLineArgs.Length > 1 Then
Dim args As String() = Environment.GetCommandLineArgs()
Select Case args(1)
Case "update"
Dim ps As Process() = Process.GetProcessesByName(args(2))
For Each p As Process In ps
p.Kill()
p.WaitForExit()
Next
IO.File.Delete(args(2) & ".exe")
End Select
End IfC#
Code
if (Environment.GetCommandLineArgs().Length > 1)
{
string[] args = Environment.GetCommandLineArgs();
switch (args[1])
{
case "update":
System.Diagnostics.Process[] ps = System.Diagnostics.Process.GetProcessesByName(args[2]);
foreach (System.Diagnostics.Process p in ps)
{
p.Kill();
p.WaitForExit();
}
System.IO.File.Delete(args[2] + ".exe");
break;
}
}WAIT BUT HOW DOES THIS WORK?!...
It's simple, you get your application to download the new exe to the SAME directory your applications currently in.
Then you get your application to start the new exe with the code below.
the new exe will then close and delete the old one.
VB .Net
Code
Process.Start("new.exe", "update " & My.Application.Info.AssemblyName)C#
Code
Process.Start("new.exe", "update " + this.GetType().Assembly.GetName().Name.ToString());