开发者

how to use Process.Start() for one of the builtin user accounts?

I was wondering if there is a way to start a process that runs as one of the builtin service accounts? I want to start the process for managed code. I want to use one of the builtin serv开发者_如何转开发ice accounts (LocalService, NetworkService, LocalSystem).


I think you could use psexec as an intermediary to launch a process under the LocalSystem (aka System) account:

Run Regedit interactively in the System account to view the contents of the SAM and SECURITY keys:

psexec -i -d -s c:\windows\regedit.exe

But I can't think of a way to launch under the other accounts. About the only indirect way I could think of to do this would be to have a service already running under the appropriate account, and then connect to it (via e.g. remoting, pipes, WCF, whatever works for you) and ask it to launch the new process.

Of course, in that instance, the new process could not interact with the desktop, so if you needed that, you'd still be out of luck.


I think you can only do this from within the context of another service (or maybe just running as LocalSystem is enough); in that case you can use LogonUser() to get the token. Alternatively, you could try to find an existing service running under the desired account and duplicate its token (assuming you have the appropriate access to do so).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜