AutoUpdater.NET icon indicating copy to clipboard operation
AutoUpdater.NET copied to clipboard

Option to pass update information to start method

Open sarul84 opened this issue 7 years ago • 2 comments

Hi, Is there any way I can pass updater information such as downloadURL, current version to start method without using the XML file as we keep those details in the database?

I am also looking for a way to download and run the update using the service account. Is this possible?

sarul84 avatar Mar 20 '19 06:03 sarul84

When you start the program get your info from database into variables then create temporary update.xml using those variables in temp folder and pass that file path URL to Start() method.

DjordjeMandic avatar Mar 20 '19 16:03 DjordjeMandic

Hi, Thanks for your response. Yes, right now, I am doing the same but looking for some elegant solution because I don't want to manage file writing/cleanup things. I felt that if we have a way to pass updater information as an argument to the "Start" method that would be a clean and nice solution.

I came up with a solution to satisfy my second question (Run update using another account)

Add the following code snippet to AutoUpdater file

         /// <summary>
        ///     Set this to true if you want to run updater on another account other than current user or admin. Very usefull in the case of service account
        /// </summary>
        public static bool RunUpdateAsUser = false;

        /// <summary>
        ///     Set credentials for service account which will be used to invoke updater
        /// </summary>
        public static NetworkCredential ServiceAccount;

Add the following code in DownloadUpdateDialog form

            if(AutoUpdater.RunUpdateAsUser && AutoUpdater.ServiceAccount != null)
            {
                SecureString ssPwd = new SecureString();

                Array.ForEach(AutoUpdater.ServiceAccount.Password.ToCharArray(),
                    (x) => ssPwd.AppendChar(x));
                ssPwd.MakeReadOnly();

                processStartInfo.Domain = AutoUpdater.ServiceAccount.Domain;
                processStartInfo.UserName = AutoUpdater.ServiceAccount.UserName;
                processStartInfo.Password = ssPwd;
            }

sarul84 avatar Mar 21 '19 06:03 sarul84