I want run my function in limited account with adm

2019-08-03 05:23发布

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.

3条回答
beautiful°
2楼-- · 2019-08-03 05:59

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.

查看更多
ら.Afraid
3楼-- · 2019-08-03 06:03

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.

查看更多
霸刀☆藐视天下
4楼-- · 2019-08-03 06:07

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

C:\> runas /noprofile /netonly /user:MYCOMPUTER\testuser "C:\Program Files\My Special Program\Program.exe"
查看更多
登录 后发表回答