0

I need to run/start an installation exe from my c# app and would like to cache/embed my admin credentials so the user does not need to see the UAC request to provide them as the users in my organisation do not have admin privileges.

I have tried to setup the SecureString for the password but NetworkCredential throws an error

SecureString theSecureString = new NetworkCredential("", "password").SecurePassword;

Process installProcess = new Process();
installProcess.StartInfo.UseShellExecute = false;
installProcess.StartInfo.UserName = "admin";
installProcess.StartInfo.Password = theSecureString;
installProcess.StartInfo.FileName = @"installer.exe";
installProcess.Start();
SivolcC
  • 3,258
  • 2
  • 14
  • 32
Les
  • 1
  • By doing this any experienced user can easily extract your password from the executable and do whatever they want with your account. This is not the correct way of doing this. I'm sorry I can't tell The Right Way because I don't do software deployment. – RedX Feb 08 '19 at 04:05
  • This looks like a duplicate of https://stackoverflow.com/questions/17908993/starting-a-process-with-a-user-name-and-password – Stuart Smith Feb 08 '19 at 04:06
  • This won't work. Even if you can run the program as an admin user, they will still see a UAC prompt, because even admin users still require separate elevation for every process. It won't prompt for credentials, but they'll still have to click to grant permissions, and they may not be able to do that while logged in as a standard user. Better is using a process like ClickOnce or SCCM to manage your installations. – Joel Coehoorn Feb 08 '19 at 04:06
  • Oh, ok. So would ClickOnce work for the installation of thrid party software installer exe? – Les Feb 08 '19 at 06:52

0 Answers0