Elevation without restarting an application?

社会主义新天地 提交于 2019-12-24 11:28:36

问题


Has anyone managed to get administration rights through the UAC without restarting the application or embedding a manifest file?

I'd like to write to some files that only administrators can modify, without relying to another elevated application. Is it possible to impersonate an administrator previously calling with some native API the UAC prompt?

I guess this is not possible and I'll have to use an external tool with elevated rights, but I'm asking just in case.

EDIT: I know there are some other similar questions around, but since they do not cover the topic of impersonation (as fas as I've seen), nor some possible native call to the UAC prompt I decided to give a new thread a go...


回答1:


As stated in this other question, it is not possible, you have can eleveate COM object or another process, but not the current process.

Request Windows Vista UAC elevation if path is protected?




回答2:


I read that thread (along with a lot more heh), but you never know what other people has managed to do recently. And maybe the release of SP2 changed something, dunno.




回答3:


Well, I guess there are no changes on how the UAC works nor any discovery on workarounds, so I'll mark the previous answer as the right one.

I'll make another application that performs the administrative tasks I need.

Thank you.




回答4:


If all you want to do it get admin rights without a manifest (ie: im assuming you're not talking about cracking/hacking the UAC implementation), then just create a shortcut with the "Run As Admin" checkbox checked. You can programmatically generate this shortcut as long as you look up how short cuts are written (in terms of their fiel contents) and I'm sure there is some name/value pair you will need to include inside the shortcut to ensure that Run As Admin is checked by default. Now, when people run that shortcut instead of your exe, they will get prompted to run your exe in elevated mode (with admin rights), and this way you will not need to restart or use a manifest.

Excuse me if I have misunderstood your question.




回答5:


Adding a manifest file in the same directory as the executable "works for me". Not actually getting the permissions, but it prompts for the permission.



来源:https://stackoverflow.com/questions/1125020/elevation-without-restarting-an-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!