C#使用缓存的管理员凭据运行安装程序

时间:2019-02-08 01:18:26

标签: c# uac

我需要从c#应用程序运行/启动安装exe,并且想缓存/嵌入我的管理员凭据,因此,由于我组织中的用户没有管理员权限,因此用户无需查看UAC请求即可提供它们特权。

我尝试为密码设置SecureString,但是NetworkCredential抛出错误

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();

0 个答案:

没有答案