开发者

How to Install a service as the current account in c#

In my installer code I'm currently using:

 processInstaller.Account = ServiceAccount.LocalSystem;
开发者_开发百科

But one of our clients has a proxy configured so the service account can't access the internet. Currently we have to configure all the services manually after install but if we could have them automatically use the credentials of the installing user we wouldn't have to do this. Does anyone know if this can be done?

Thanks, Richard


You can set the Account type to user and then specify a username and password.

processInstaller.Account = ServiceAccount.User;
processInstaller.User = "domain\username";
processInstaller.Password = "Password";


http://msdn.microsoft.com/en-us/library/system.serviceprocess.serviceaccount.aspx Prompt user to enter user account and password he wish to install with, and set those credential to account

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜