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

被折叠的 条评论
为什么被折叠?



