Option to pass update information to start method
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?
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.
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;
}