Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to run update in the background #642

Open
bvn63 opened this issue Oct 19, 2023 · 2 comments
Open

How to run update in the background #642

bvn63 opened this issue Oct 19, 2023 · 2 comments

Comments

@bvn63
Copy link

bvn63 commented Oct 19, 2023

Hi everybody,

Is there a way to run it in the background? That is, it does not display the update window to the user. Even though I have set the winform to minimize when running, it still displays the update window.

Anyone can help me, I appreciate your help.

Thank you.

@ravibpatel
Copy link
Owner

You can handle the update logic manually as shown here, but if you use AutoUpdater.DownloadUpdate method as shown in the example, then it will still show the download dialog. To remedy that, you can handle the download logic in the event. It will be much easier if you are using installer as an update file. You just have to download the update EXE using something like HttpClient and after the download finishes just execute the update EXE.

@bvn63
Copy link
Author

bvn63 commented Oct 24, 2023

You can handle the update logic manually as shown here, but if you use AutoUpdater.DownloadUpdate method as shown in the example, then it will still show the download dialog. To remedy that, you can handle the download logic in the event. It will be much easier if you are using installer as an update file. You just have to download the update EXE using something like HttpClient and after the download finishes just execute the update EXE.

Hi ravibpatel,
Thank you for your opinion, I have configured as you said above but there is an error that sometimes it does not download the file even though AssemblyVersion is in the application > AssemblyVersion in xml, when I have free time I will check again.
Louis.

var currentDirectory = new DirectoryInfo(Application.StartupPath);
if (currentDirectory.Parent != null)
{
//AutoUpdater.InstallationPath = currentDirectory.Parent.FullName;
AutoUpdater.InstallationPath = currentDirectory.FullName;
}

AutoUpdater.Start("http://192.168.11.71/MYAPP/update.xml");
AutoUpdater.RunUpdateAsAdmin = false;
AutoUpdater.Mandatory = true;
AutoUpdater.UpdateMode = Mode.ForcedDownload;
AutoUpdater.DownloadPath = currentDirectory.FullName + "\Download\";
AutoUpdater.CheckForUpdateEvent += AutoUpdaterOnCheckForUpdateEvent;

private void AutoUpdaterOnCheckForUpdateEvent(UpdateInfoEventArgs args)

if (args.Error == null)
{
if (args.IsUpdateAvailable)
{
DialogResult dialogResult;
if (args.Mandatory.Value)
{
//
}
else
{

         try
         {
                  DownloadAndSave("http://192.168.11.71/MYAPP/TestUpdate.zip", AutoUpdater.InstallationPath + "Download\\", "TestUpdate.zip");
                 Application.Exit();
                 ZipFile.ExtractToDirectory(AutoUpdater.InstallationPath + "Download\\TestUpdate.zip", AutoUpdater.InstallationPath ,true);
            

         }
         catch (Exception exception)
         {
             MessageBox.Show(exception.Message, exception.GetType().ToString(), MessageBoxButtons.OK,
                 MessageBoxIcon.Error);
         }
     }

 }

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants