可执行文件是否可以要求管理员权限? (Windows 7的) [英] Is it possible for the executable to ask for Administrator rights? (Windows 7)

查看:291
本文介绍了可执行文件是否可以要求管理员权限? (Windows 7的)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个分区磁盘程序,我要读取 \\\\.\\PhysicalDrive0 我需要管理员权限。 / p>

我想知道在运行时是否可以让程序获得管理员权限?有没有胜利的api?



我想这样做,因为我想让程序只有在读/写磁盘时才能以管理员权限执行。出于安全原因,我不想让程序一直执行管理员权限,因为有人可能在某些模块中发现错误(例如堆栈或堆溢出),并执行任意命令作为adm。

解决方案

在进程启动后,您无法获取提升的权限。您的选项是:


  1. 将需要提升权限的应用程序部分放入一个单独的进程中,并显示 require


  2. 将需要提升权限的应用程序的一部分作为未处理的COM对象运行。


    1. I am developing a partition disk program, and for me to read the \\\\.\\PhysicalDrive0 I need admin rights.

      I am wondering if it is possible, in the run time, for the program to gain admin rights? Is there any win api for that?

      I want to do that because I want the program to execute with admin rights only when it is reading/writing the disk. For security reasons, I don't want the program to execute all the time with admin rights, because someone could find a bug (stack or heap overflow for example) in some module and execute arbitrary commands as adm.

      解决方案

      You cannot acquire elevated privileges after the process has started. Your options are:

      1. Put the part of your application that requires elevated privileges into a separate process and manifest that with requireAdministrator.
      2. Run the part of your application that requires elevated privileges as an out-of-proc COM object.

      这篇关于可执行文件是否可以要求管理员权限? (Windows 7的)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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