开发者

I want run my function in limited account with administrator permission

I want run my program under a limited user account but with administra开发者_高级运维tor 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.


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

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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜