Elevation and process creation APIs

本文详细介绍了InVista环境下,CreateProcess和ShellExecute API在处理UAC权限提升需求时的不同表现。尤其指出,CreateProcess在遇到需要管理员权限的可执行文件时会返回ERROR_ELEVATION_REQUIRED错误,而ShellExecute则能适当地弹出提升权限对话框。此外,文章还提出了通过编写小应用程序调用ShellExecute来启动目标应用的方法,以实现不受manifest和配置影响的提升权限操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

In Vista, process creation APIs behave very differently with respect to UAC.  If you call CreateProcess() on an executable which is manifested as “RequireAdministrator” or is flagged as an installer by Vista, you will get back an ERROR_ELEVATION_REQUIRED (740) error.  ShellExecute() will behave appropriately (pop up the elevation / credential dialog).  As mentioned in an earlier blog, ShellExecute() allows you to define a ‘runas’ verb which will trigger elevation on the process regardless of manifest, etc. 

CreateProcessAsUser() functions like CreateProcess in that it will return an elevation required error.  If you want to launch a process from a service which will run elevated, one method of accomplishing this would be to write a small bootstrapping type application which calls ShellExecute() to launch the target app.  This would allow you to launch any application as if it were manifested with “RequireAdministrator”.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值