I need to ensure that my widnows app (winform not console) runs under a certain user account (in other words any user can be logged on to the maching but the .exe will always execute as the specified user).
Can this be done programtically? If so, how?
You can start the application like this:
ProcessStartInfo psi = new ProcessStartInfo(myPath);
psi.UserName = username;
SecureString ss = new SecureString();
foreach (char c in password)
{
ss.AppendChar(c);
}
psi.Password = ss;
psi.UseShellExecute = false;
Process.Start(psi);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With