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

Option to run update on another user account #252

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion AutoUpdater.NET/AutoUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,16 @@ public static class AutoUpdater
/// If this is true users can see the skip button.
/// </summary>
public static Boolean ShowSkipButton = true;

/// <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;

/// <summary>
/// If this is true users can see the Remind Later button.
Expand Down Expand Up @@ -821,4 +831,4 @@ public override string ToString()
return $"Basic {token}";
}
}
}
}
14 changes: 13 additions & 1 deletion AutoUpdater.NET/DownloadUpdateDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,18 @@ private void WebClientOnDownloadFileCompleted(object sender, AsyncCompletedEvent
{
processStartInfo.Verb = "runas";
}

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

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

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

try
{
Expand Down Expand Up @@ -334,4 +346,4 @@ protected override WebResponse GetWebResponse(WebRequest request, IAsyncResult r
return webResponse;
}
}
}
}