简体   繁体   English

ProcessStartInfo 动词 runas 不起作用

[英]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.

相关问题 ProcessStartInfo动词运行方式? - ProcessStartInfo Verb runas? 当Verb =“runas”时设置ProcessStartInfo.EnvironmentVariables - Set ProcessStartInfo.EnvironmentVariables when Verb=“runas” 动词=“ runas”未以提升的方式运行 - Verb = “runas” not run as elevated ProcessStartInfo不包含“动词”的定义 - ProcessStartInfo does not contain a definition for 'Verb' WiX CustomAction 的子进程忽略 -Verb runAs - Child process of WiX CustomAction ignores -Verb runAs 工作目录的 ProcessStartInfo 问题 - ProcessStartInfo problem with working directory 使用Verb =“runas”的进程不会以Arguments中定义的凭据开头 - Process with Verb = “runas” does not start with the credentials defined in Arguments ServiceStack-ApiMember动词-不起作用 - ServiceStack - ApiMember Verb - Not Working 标准规范动词的ProcessStartInfo.Verbs属性返回的动词字符串是否因文化而异? - Are the verb strings the ProcessStartInfo.Verbs propery returns for Standard Canonical Verbs different based on culture? 使用ShellExecuteEx和动词“ runas”运行应用程序时如何预选管理员? (Windows XP) - How to preselect Administrator when running an application using ShellExecuteEx with verb “runas”? (Windows XP)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM