安装Windows服务出现错误

发布于 2024-09-12 23:53:40 字数 999 浏览 8 评论 0原文

我在本地 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

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

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

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

请帮助我

I created a simple windows service on my local PC and added the following code to it

 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

Next I added a Setup project to this solution and added a custom action (By double clicking application folder then clicking add output folder then selecting primary output from the dialog). The solution builds fine but I have 2 problems.

1) Everytime I install the service, it asks me for the username, password and confirm password; I was wondering if there was anyway to get rid of it atleast while running locally. I tried setting the account type to user, local service, local system etc but it keeps popping up.

2) Once I enter the credentials (random ones), I get an error "No mapping between account names and security ids was done".

Kindly help me out

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

铃予 2024-09-19 23:53:40

1:您可以按照 codeproject 文章中的方式自行安装服务,然后只需将您要使用的用户名/密码发送到 ServiceProcessInstaller 即可。

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

1: You could make your service be selfinstalling as in this codeproject article and then just send in the username/password you want to use to the ServiceProcessInstaller.

2: Try entering the credentials in a different format. If you're currently using ".\user" try writing "computer\user" or vice versa.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文