一个进程在启动后能自我提升吗? [英] Can a process elevate itself after startup?

查看:27
本文介绍了一个进程在启动后能自我提升吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

进程启动后是否有可能获得管理员权限?如果是这样,如何?

Is it possible for a process to gain administrator priviledges after it has started? If so, how?

示例应使用 C 或 C++.

Examples should be in C or C++.

编辑 - 示例也应该使用 umanaged 代码.

Edit - Examples should also use umanaged code.

推荐答案

您无法在进程运行时提升进程的权限.解决此问题的常用方法是在需要时生成具有提升权限的新进程.该进程然后执行需要更高权限的工作,然后退出,将控制权释放回主进程.通过将新进程父窗口设置为主进程窗口的父窗口,您应该能够使其相当无缝.

You cannot elevate the permissions of a process while the process is running. the common way around this is to spawn a new process with elevated permissions when required. This process then does the work that requires higher privileges and then quits, releasing control back to the main process. You should be able to make it fairly seamless by setting the new processes parent window to that of the main process window.

另一种选择是使用所需的权限重新启动主程序.

The other alternative is relaunch the main program with the required permissions.

有一个 关于在 Vista 中使用 UAC 的文章,带有 C++ 示例,看起来很深入.

There is an article on UAC in Vista with C++ examples that looks quite in depth.

这篇关于一个进程在启动后能自我提升吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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