c#安装windows服务时提示用户名密码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1945536/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 22:06:47  来源:igfitidea点击:

Prompting username password while installing the windows service in c#

c#

提问by Partha

I am being prompted for user name and password while installing my windows service created in c#. I used the installutil tool to install my service. What is the reason for asking the user name password credentials?

安装在 c# 中创建的 Windows 服务时,系统提示我输入用户名和密码。我使用 installutil 工具来安装我的服务。询问用户名密码凭据的原因是什么?

回答by Oded

Your windows service needs a user name and password for the same reason that you are asked for your username and password on login. To identify you and to set your access levels and permissions on windows.

您的 Windows 服务需要用户名和密码,原因与登录时要求您输入用户名和密码的原因相同。在 Windows 上识别您并设置您的访问级别和权限。

This is not a problem, it is supposed to work this way.

这不是问题,它应该以这种方式工作。

回答by this. __curious_geek

Every process or service in windows runs under a particular windows user account.

Windows 中的每个进程或服务都在特定的 Windows 用户帐户下运行。

The user account is used as identity for any action performed by the service or the process. If your process or service requires to do any task which requires security privileges, it will be granted only on basis of the user-identity associated with the process/service.

用户帐户用作服务或进程执行的任何操作的标识。如果您的流程或服务需要执行任何需要安全权限的任务,则将仅根据与流程/服务相关联的用户身份进行授予。

Say you're running you service under a user named "SVCUSER" and the service requires to do disk I/O in any location of the disk. If the user "SVCUSER" does not have rights or authorization to perform disk I/O for the given location, the service will not be able perform the operation and throw related security-exception.

假设您在名为“SVCUSER”的用户下运行您的服务,并且该服务需要在磁盘的任何位置执行磁盘 I/O。如果用户“SVCUSER”没有为给定位置执行磁盘 I/O 的权限或授权,则服务将无法执行该操作并抛出相关的安全异常。

回答by Satyendra Kumar

If you do not want your windows service to prompt for Username/Password, go to Installer Class(Design Mode)of the service, then right click on ServiceProcessInstaller -> Properties; set Accountas Local Service.

如果您不希望 Windows 服务提示输入用户名/密码,请转到Installer Class(Design Mode)服务的 ,然后右键单击ServiceProcessInstaller -> Properties; 设置AccountLocal Service

Now use the installutilcommand. It will not ask for Username/Password.

现在使用installutil命令。它不会询问用户名/密码。

回答by sathiyamoorthy

Right click ServiceProcessInstaller file - > go to properties - > Choose account as LocalService.

右键单击ServiceProcessInstaller 文件-> 转到属性-> 选择帐户为LocalService。

enter image description here

在此处输入图片说明