[英]Running a loop of processes that require admin rights
I have an application that does a loop which starts some processes programmatically one by one.我有一个执行循环的应用程序,它以编程方式一个接一个地启动一些进程。 My app itself runs under a standard user, but I need to run only those processes as admin so I can install them.
我的应用程序本身在标准用户下运行,但我只需要以管理员身份运行这些进程,以便我可以安装它们。
To achieve this, I use the 4th response from this thread为了实现这一点,我使用了这个线程的第四个响应
My two questions are:我的两个问题是:
is that code which is pointed in the above response, supposed to ensure that the process automatically runs as admin, or that the user is shown a dialog where he chooses whether to run as admin or not?上面的响应中指出的代码是否应该确保进程自动以管理员身份运行,或者向用户显示一个对话框,让他选择是否以管理员身份运行? I am confused by what this code is supposed to do.
我对这段代码应该做什么感到困惑。
Also, in case a dialog is supposed to be given to the user - how can the app be coded, so that the first user option is remembered in my loop for the next processes started with the verb "runas"?此外,如果应该向用户提供一个对话框 - 如何对应用程序进行编码,以便在我的循环中记住第一个用户选项以用于以动词“runas”开始的下一个进程? So basically to store somewhere the user option (run as admin or not) for the other processes.
所以基本上将其他进程的用户选项(以管理员身份运行或不以管理员身份运行)存储在某处。
Thank you in advance先感谢您
First question: It is how to start an elevated process from a non-elevated one.第一个问题:如何从一个非提升的过程开始一个提升的过程。
Second question: there isn't -- or at least shouldn't.第二个问题:没有——或者至少不应该。 -- be any way for a non-elevated process to elevate anything without a user prompt, The best solution for your program is either to start it off with admin rights.
- 以任何方式让非提升进程在没有用户提示的情况下提升任何内容,您的程序的最佳解决方案是使用管理员权限启动它。 or to use the first elevation request as an opportunity to restart with them (using the technique you linked to).
或使用第一个提升请求作为重新启动它们的机会(使用您链接到的技术)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.