开发者

Switch user that services run as dynamically

I have a Windows Service that runs, and currently, it runs under whatever account instal开发者_Go百科led the service onto the computer.

Is there some way, using code, that I can switch the active user that the service runs as, dynamically, without any user interaction or GUI? I'm a little inexperienced when it comes to services, so I'm not sure if this is possible. Any info on the topic would be appreciated. (VB and C# code is okay)


Assuming you included a class that inherits from Installer as part of your service code to handle the service installation you can change the Account for the Service Process Installer component to specify LocalService, NetworkService, LocalSystem or User. However, if you specify User then you will either need to encode the username and password in the code. If you set it to User and don't provide these values then when InstallUtil.exe is run to install the service it will prompt for the Username and Password.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜