I want run my function in limited account with adm

2019-08-03 05:50发布

问题:

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.