[英]ProcessStartInfo Verb runas not working
What is wrong with the following code?以下代码有什么问题?
ProcessStartInfo startInfo = default(ProcessStartInfo);
startInfo = new ProcessStartInfo(SetupProgramPath)
{
UseShellExecute = true,
Verb = "runas",
WindowStyle = ProcessWindowStyle.Normal,
CreateNoWindow = false
};
Process.Start(startInfo);
It is expected to prompt for credentials but nothing shows up.预计会提示输入凭据,但没有显示任何内容。 The system has the UAC enabled and not supposed to be changed.系统已启用 UAC,不应更改。 I appreciate your help in this one.我很感激你在这方面的帮助。 Thank you in advance.先感谢您。
I have worked this out with the following code我已经用以下代码解决了这个问题
ProcessStartInfo startInfo = default(ProcessStartInfo);
startInfo = new ProcessStartInfo(SetupProgramPath)
{
UseShellExecute = true,
Verb = "runas",
WindowStyle = ProcessWindowStyle.Normal,
FileName = "msiexec",
Arguments = "/i \"" + SetupProgramPath + "\"",
CreateNoWindow = false
};
Process.Start(startInfo);
If you want to ask the user to enter credentials of a different user, then use "runasuser":如果您想要求用户输入其他用户的凭据,请使用“runasuser”:
ProcessStartInfo startInfo = new ProcessStartInfo(SetupProgramPath)
{
UseShellExecute = true,
Verb = "runasuser",
WindowStyle = ProcessWindowStyle.Normal,
CreateNoWindow = false
};
Process.Start(startInfo);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.