以用户身份安装Windows服务失败

我正在使用.Net framework 3.5版开发Windows服务。 它需要在远程计算机上调用Web服务,我遇到了一个奇怪的安装问题。

我曾经在我的机器上安装它作为User (默认),并在提示时提供我的登录名和密码,一切正常。 然后在某些时候,它停止工作,我发现将其安装为LocalSystem并且工作正常。

现在我正在尝试调用远程Web服务,我从WCF收到错误:

 There was no endpoint listening at https://www.remote.com/webservice.asmx that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. 

显然,这可能是由于将服务作为LocalSystem (没有Internet访问权限)运行: 没有端点侦听可以接受该消息。 这通常是由不正确的地址或SOAP操作引起的

所以,我已经尝试切换回以User身份安装服务并提供我的凭据(我应该注意,此时我是我的机器的管理员)。 但它不起作用,错误消息(以及InstallUtil日志文件的内容)旁边是无用的:

 Running a transacted installation. Beginning the Install phase of the installation. See the contents of the log file for the Service.exe assembly's progress. The file is located at Service.InstallLog. An exception occurred during the Install phase. System.InvalidOperationException: An exception occurred in the OnAfterInstall event handler of System.ServiceProcess.ServiceInstaller. The inner exception System.InvalidOperationException was thrown with the following error message: Service ServiceName was not found on computer '.'. The inner exception System.ComponentModel.Win32Exception was thrown with the following error message: The specified service does not exist as an installed service. The Rollback phase of the installation is beginning. See the contents of the log file for the Service.exe assembly's progress. The file is located at Service.InstallLog. The Rollback phase completed successfully. The transacted install has completed. 

据我所知,相关的一点是该服务无法安装。 没有更多信息! 任何想法为什么服务可能作为LocalSystem成功安装但在安装为Administrators组成员的User时失败?

尝试使用NetworkService用户。 出于安全原因,不允许LocalService与外界建立连接。

至于您无法自行安装服务的原因,这可能是由UAC引起的。 我发现除非UAC完全关闭,否则安装服务是不可能的,即使您是帐户的管理员也是如此。 这是因为您的帐户没有此特权。 我相信您可以通过组策略管理器解决此问题。