Using InstallUtil and silently setting a windows service logon username/password

后端 未结 5 1545
花落未央
花落未央 2020-12-22 23:29

I need to use InstallUtil to install a C# windows service. I need to set the service logon credentials (username and password). All of this needs to be done silently.

<
5条回答
  •  执笔经年
    2020-12-23 00:33

    You can also force your service to run as User using ServiceProcessInstaller::Account = ServiceAccount.User;

    A popup asking "[domain\]user, password" will appear during service installation.

    public class MyServiceInstaller : Installer
    {
        /// Public Constructor for WindowsServiceInstaller
        public MyServiceInstaller()
        {
            ServiceProcessInstaller serviceProcessInstaller = new ServiceProcessInstaller();
            ServiceInstaller serviceInstaller = new ServiceInstaller();
    
            //# Service Account Information
            serviceProcessInstaller.Account = ServiceAccount.User; // and not LocalSystem;
         ....
    

提交回复
热议问题