【问题标题】:Installing Windows services gives an error安装 Windows 服务会报错
【发布时间】:2010-08-03 07:16:34
【问题描述】:

我在本地 PC 上创建了一个简单的 windows 服务,并在其中添加了以下代码

 Protected Overrides Sub OnStart(ByVal args() As String)
    Const iTIME_INTERVAL As Integer = 60000      ' 60 seconds.
    Dim oTimer As System.Threading.Timer

    System.IO.File.AppendAllText("C:\AuthorLog.txt", _
        "AuthorLogService has been started at " & Now.ToString())

    Dim tDelegate As Threading.TimerCallback = AddressOf EventAction
    oTimer = New System.Threading.Timer(tDelegate, Me, 0, iTIME_INTERVAL)
End Sub

Protected Overrides Sub OnStop()

End Sub


Public Sub EventAction(ByVal sender As Object)
    System.IO.File.AppendAllText("C:\AuthorLog.txt", _
        "AuthorLogService fires EventAction at " & Now.ToString())
End Sub

接下来,我向此解决方案添加了一个安装项目并添加了一个自定义操作(通过双击应用程序文件夹,然后单击添加输出文件夹,然后从对话框中选择主要输出)。解决方案构建良好,但我有 2 个问题。

1) 每次我安装服务时,它都会要求我输入用户名、密码和确认密码;我想知道至少在本地运行时是否有办法摆脱它。我尝试将帐户类型设置为用户、本地服务、本地系统等,但它不断弹出。

2) 输入凭据(随机凭据)后,我收到错误消息“未完成帐户名称和安全 ID 之间的映射”。

请帮帮我

【问题讨论】:

    标签: vb.net windows-services setup-project


    【解决方案1】:

    1:您可以像this codeproject 文章中那样让您的服务自行安装,然后只需将您要使用的用户名/密码发送到ServiceProcessInstaller

    2:尝试以不同的格式输入凭据。如果您当前使用的是“.\user”,请尝试编写“computer\user”,反之亦然。

    【讨论】:

    • 使用installutil.exe在服务器上安装服务,我实际上不得不使用.\user选项而不是domain\user,我认为这是正确的选项。
    猜你喜欢
    • 2019-02-22
    • 2011-09-11
    • 1970-01-01
    • 1970-01-01
    • 2015-11-19
    • 2018-09-21
    相关资源
    最近更新 更多