I want run my function in limited account with administrator permission

耗尽温柔 提交于 2019-12-11 07:18:51

问题


I want run my program under a limited user account but with administrator privileges on windows XP.

I can't find an answer. I think I can use two ways:

  1. Run my program by another way like a program or a service
  2. Run my function with some method like PrincipalPermission space or something like this

But I can't solve this problem.


回答1:


One way to solve this is to fragment your program into two parts. One part as a windows service and the one as a user app. You can set the service to run as a Network Service, Local Service or Local System depending the level of access you need. Anything that needs administrator privileges will be performed by the Windows service. The user app can be responsible for showing the user interface and other similar things. You need to have some kind of IPC (Inter process communication) between your applications to facilitate this as well.




回答2:


Have you looked at the "runas" command? For example:

C:\> runas /noprofile /netonly /user:MYCOMPUTER\testuser "C:\Program Files\My Special Program\Program.exe"



回答3:


I want run my program under a limited user account but with administrator privileges.

This can't be done. A limited user doesn't have admin privileges. You need to run it as an admin user with, e.g. runas.



来源:https://stackoverflow.com/questions/5731632/i-want-run-my-function-in-limited-account-with-administrator-permission

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