Windows服务安装 [英] Windows Service Installation

查看:85
本文介绍了Windows服务安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个Windows服务,该服务需要读取用户名 .bin文件.
我可以编写服务,并且如果我使用
登录,它将可以正常工作 帐户= System.ServiceProcess.ServiceAccount.LocalService
但然后Environment.UserName返回 System 而不是 username
也无法访问Windows注册表.

如果我使用
帐户= System.ServiceProcess.ServiceAccount.User,我需要输入用户名和密码.就我而言,我可以执行此操作,而InstallUtil确实可以安装它,但是当我尝试启动服务时,出现错误消息1069:登录失败

请提供帮助.

I want to write a windows service that needs to read a username.bin file.
I can write the service and it works if I log in using
Account = System.ServiceProcess.ServiceAccount.LocalService
but then Environment.UserName returns System instead of username
nor can I access the Windows Registry.

If I use
Account = System.ServiceProcess.ServiceAccount.User, I need to enter the UserName and Password. In my case I can do this and InstallUtil does install it, but when I try to Start the Service, I get error message 1069: logon failure

Help please

推荐答案

该服务将必须作为LocalSystem运行.您还必须订阅登录/注销消息,以查找谁登录(也可以同时有多个人登录!)

提供的用户帐户和密码不起作用的原因是,必须专门设置一个帐户才能作为服务登录.普通用户帐户无效.

至于获取这些通知,请查看 [ ^ ]和 [
The service will have to run as LocalSystem. You''ll also have to subscribe for login/logout messages in order to find out who''s logged in (there can also be MULTIPLE people logged in at the same time!)

The reason why the supplied user account and password don''t work is because an account must be setup specially to login as a service. Normal user account don''t work.

As for getting those notifications, look at this[^] and this[^].


这篇关于Windows服务安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆