简体   繁体   中英

Installing a windows service as another user than Network Service

I am using a self-installing variant to install my windows service. That means I run the exe that makes up the service, and when run it installs itself using the following line of code:

ManagedInstallerClass.InstallHelper(new[] { Assembly.GetExecutingAssembly().Location });

This works fine, and the service gets added to the list of services. My only problem is that this service gets added with Log On As equal to Network Service . I am doing certain operations from this service that require it to log on as Local System .

How can I make it install itself to run as Local System instead of Network Service ?

I think you are using ServiceProcessInstaller . If so, you can set ServiceAccount.LocalSystem to its Account property

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM