Make app restart itself upon updating.

Hello,

I'm evaluating wyBuild and is an amazing product. But I haven't been able to make my app (a toy app) to restart itself upon updating. The best I've got is to get an (i) icon with a message "application will be updated next time" and have click on the context menu to actually update it.

Any tips for a newcomer?

Thanks,

Paulo

If you're using the AutomaticUpdater component then your app will automatically restart upon updating.

If you're just using wyUpdate.exe by itself then are multiple options for restarting your app after an update:

https://wyday.com/wybuild/help/executing-files.php

https://wyday.com/wybuild/help/wyupdate-commandline.php#startonerr

Yes, I am using automatic updater but it is not restarting the application without user intervention. It only changes its icon (and message) until I manually select to update the app. Only then it starts the update process.

I've tried to handle its events but the updater component isn't firing any.

Here's some code:

// -- Form1.cs#Form1

public partial class Form1 : Form { private static string CurrentVer = "1.1";

public Form1() { InitializeComponent(); if (automaticUpdater.ClosingForInstall) return; }

private void Form1_Load(object sender, EventArgs e) { textBox1.Text = CurrentVer; textBox2.Text = "?"; automaticUpdater.ForceCheckForUpdate(); Log("Form loaded"); }

private void automaticUpdater_UpdateAvailable(object sender, EventArgs e) { Log("Update Available"); automaticUpdater.InstallNow(); }

private void automaticUpdater_CloseAppNow(object sender, EventArgs e) { Log("Force exit"); Application.Exit(); }

private void Log(string format, params object[] values) { logger.Text += string.Format(format, values) + "\n"; } }

/////// Form1.designer.cs#Form1

partial class Form1 { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null;

/// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); }

#region Windows Form Designer generated code

/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.label1 = new System.Windows.Forms.Label(); this.textBox1 = new System.Windows.Forms.TextBox(); this.label2 = new System.Windows.Forms.Label(); this.textBox2 = new System.Windows.Forms.TextBox(); this.automaticUpdater = new wyDay.Controls.AutomaticUpdater(); this.logger = new System.Windows.Forms.TextBox(); ((System.ComponentModel.ISupportInitialize)(this.automaticUpdater)).BeginInit(); this.SuspendLayout(); // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(12, 13); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(42, 13); this.label1.TabIndex = 0; this.label1.Text = "AppVer"; // // textBox1 // this.textBox1.Location = new System.Drawing.Point(61, 6); this.textBox1.Name = "textBox1"; this.textBox1.Size = new System.Drawing.Size(100, 20); this.textBox1.TabIndex = 1; // // label2 // this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(12, 40); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(37, 13); this.label2.TabIndex = 2; this.label2.Text = "LibVer"; // // textBox2 // this.textBox2.Location = new System.Drawing.Point(61, 33); this.textBox2.Name = "textBox2"; this.textBox2.Size = new System.Drawing.Size(100, 20); this.textBox2.TabIndex = 3; // // automaticUpdater // this.automaticUpdater.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.automaticUpdater.ContainerForm = this; this.automaticUpdater.GUID = "73c12b82-16c6-449a-bb9a-3806bee23f9a"; this.automaticUpdater.Location = new System.Drawing.Point(256, 12); this.automaticUpdater.Name = "automaticUpdater"; this.automaticUpdater.Size = new System.Drawing.Size(16, 16); this.automaticUpdater.TabIndex = 4; this.automaticUpdater.wyUpdateCommandline = null; this.automaticUpdater.CloseAppNow += new System.EventHandler(this.automaticUpdater_CloseAppNow); this.automaticUpdater.UpdateAvailable += new System.EventHandler(this.automaticUpdater_UpdateAvailable); // // logger // this.logger.Location = new System.Drawing.Point(12, 64); this.logger.Multiline = true; this.logger.Name = "logger"; this.logger.Size = new System.Drawing.Size(259, 185); this.logger.TabIndex = 5; // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(284, 261); this.Controls.Add(this.logger); this.Controls.Add(this.automaticUpdater); this.Controls.Add(this.textBox2); this.Controls.Add(this.label2); this.Controls.Add(this.textBox1); this.Controls.Add(this.label1); this.Name = "Form1"; this.Text = "Form1"; this.Load += new System.EventHandler(this.Form1_Load); ((System.ComponentModel.ISupportInitialize)(this.automaticUpdater)).EndInit(); this.ResumeLayout(false); this.PerformLayout();

}

#endregion

private System.Windows.Forms.Label label1; private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.Label label2; private System.Windows.Forms.TextBox textBox2; private wyDay.Controls.AutomaticUpdater automaticUpdater; private System.Windows.Forms.TextBox logger; }

The next time you start your app (if you're following the instructions) it will automatically install the update and restart your app.

See: https://wyday.com/wybuild/help/walkthrough.php

https://wyday.com/wybuild/help/automatic-updates/

I've followed the tutorials and got the same result as in your video.

When I close and reopen the application, it gets updated. Still, it is depending on the final user to act. My intent is to not allow a final user to run an older version after a new version is issued.

Can auto updater restart the application without user intervention? If that's possible, that's not explained in the tutorial or the video.

Simply call the appropriate function when you get the event that the update has downloaded and is ready to be installed.

https://wyday.com/wybuild/help/automatic-updates/members.php