简体   繁体   English

Process.Start创建一个弹出窗口

[英]Process.Start creates a pop window

I've an exe which runs a process to open the DeviceManager. 我有一个运行进程打开DeviceManager的exe。 But unfortunately, it asks for a confirmation to provide 'yes' or 'No' which waits for user input for long time and does not continue with execution. 但不幸的是,它要求确认提供“是”或“否”等待用户输入很长时间并且不继续执行。

How to get rid of this? 如何摆脱这个? I do not want to provide a confirmation again as I do not want to pause the EXE run with this. 我不想再提供确认,因为我不想暂停EXE运行。

StartInfo.CreateWindow = false would not hold for this as it just for starting in another cmd window. StartInfo.CreateWindow = false不适用于此,因为它只是在另一个cmd窗口中启动。

Code below: 代码如下:

Process p = new Process();
p.StartInfo.FileName = "devcon.exe";
p.StartInfo.CreateNoWindow = false;
p.Start();

The messagebox you are seeing is UAC (User Account Control) which was implemented since Vista. 您看到的消息框是自Vista以来实施的UAC (用户帐户控制)。

To bypass the box you might be able to try providing the credentials programmatically before launching the process, I can't test but something like this: 要绕过这个盒子,您可以尝试在启动过程之前以编程方式提供凭据,我无法测试但是这样的事情:

var processInfo = new ProcessStartInfo 
{ 
    FileName = "devcon.exe", 
    UserName = "Administrator", 
    Domain = "yourdomain or leave blank", 
    Password = adminpassword, 
    UseShellExecute = false,
}; 
Process.Start(processInfo);

Otherwise the user will have to have admin rights, or the password! 否则,用户必须拥有管理员权限或密码!

The other option would be to disable UAC. 另一种选择是禁用UAC。 However that wouldn't allow the user to do anything they couldn't do normally, it will probably tell you that you can't make any changes without the process running as admin. 但是,这不允许用户执行任何他们无法正常执行的操作,它可能会告诉您如果没有以管理员身份运行该进程,则无法进行任何更改。

The parent process should be run by administrator account. 父进程应由管理员帐户运行。 Also show all code please. 还请显示所有代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM