如何在没有提升的情况下回归创建流程? [英] How to fall back to creating a process without elevation?

查看:36
本文介绍了如何在没有提升的情况下回归创建流程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,它使用CreateProcess()来执行reg.exe来创建一些注册表项。其中一些需要提升权限才能创建,因此根据用户是否提升,我会跳过这些权限。但是,我遇到了一个问题,那些管理员但没有提升的
用户,尝试运行reg.exe总是失败,给出了ERROR_ELEVATION_REQUIRED。

I have an application which uses CreateProcess() to execute reg.exe to create some registry keys. Some of these require elevated privileges to create, so depending on whether the user is elevated I skip those ones. I have run into a problem, however, with users who are administrators but not elevated, where attempting to run reg.exe always fails, giving ERROR_ELEVATION_REQUIRED.

Windows,到目前为止正如我所知,不会让应用程序自动提升,这对我来说是一件好事。但我似乎也无法找到一种方法*保持低调*。如果用户已经提升,我想使用提升的行为,否则
总是使用无效的行为,无论用户是否是管理员。有没有办法做到这一点?是否有一个建筑/设计理由为什么这是一个坏主意?

Windows, as far as I can tell, doesn't let applications automatically elevate, which strikes me as a good thing. But I also can't seem to find a way to *remain unelevated*. I'd like to use elevated behaviour if the user is already elevated, and otherwise always use unelevated behaviour, regardless of whether the user is an administrator or not. Is there a way to do this? Is there an architectural/design reason why it's a bad idea?

推荐答案


<我有一个应用程序,它使用CreateProcess()来执行reg.exe来创建一些注册表项。其中一些需要提升权限才能创建,因此根据用户是否提升,我会跳过这些权限。但是,我遇到了一个问题,那些管理员但没有提升的
用户,尝试运行reg.exe总是失败,给出了ERROR_ELEVATION_REQUIRED。

I have an application which uses CreateProcess() to execute reg.exe to create some registry keys. Some of these require elevated privileges to create, so depending on whether the user is elevated I skip those ones. I have run into a problem, however, with users who are administrators but not elevated, where attempting to run reg.exe always fails, giving ERROR_ELEVATION_REQUIRED.

Windows,到目前为止正如我所知,不会让应用程序自动提升,这对我来说是一件好事。但我似乎也无法找到一种方法*保持低调*。如果用户已经提升,我想使用提升的行为,否则
总是使用无效的行为,无论用户是否是管理员。有没有办法做到这一点?是否有一个建筑/设计理由为什么这是一个坏主意?

Windows, as far as I can tell, doesn't let applications automatically elevate, which strikes me as a good thing. But I also can't seem to find a way to *remain unelevated*. I'd like to use elevated behaviour if the user is already elevated, and otherwise always use unelevated behaviour, regardless of whether the user is an administrator or not. Is there a way to do this? Is there an architectural/design reason why it's a bad idea?

我不确定你究竟是在问什么在这个帖子中。 似乎有几个嵌入式问题 -

I'm not sure exactly what you are asking in this thread.  It seems there are several embedded questions --

Q1。如何从提升的流程创建一个无法提升的流程?

Q1. How to create an unelevated process from an elevated process?

Q2。如何确定进程是否被提升以便可以选择不同的代码路径?

Q2. How to determine if a process is elevated so that different code paths can be selected?

Q3。如何自我提升流程(经用户同意)?

Q3. How to self-elevate a process (with user consent)?

这三个问题的答案 -

Answers to these three questions -

A1。请参阅
如何从我的升级过程中启动一个非高效流程,反之亦然?


https://github.com/Microsoft/Windows-classic-samples/tree/master/Samples/Win7Samples/winui/shell/appplatform/ExecInExplorer

A2& A3。请参阅
UAC自我提升(CppUACSelfElevation)
另见
https://blogs.msdn.microsoft.com/vistacompatteam / 2006/09/25 / elevate-through-shellexecute /

A2 & A3. See UAC self-elevation (CppUACSelfElevation) Also see https://blogs.msdn.microsoft.com/vistacompatteam/2006/09/25/elevate-through-shellexecute/


这篇关于如何在没有提升的情况下回归创建流程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆