当我在Visual Studio 2010中创建新的Windows服务时,我收到消息,声明使用InstallUtil和net start来运行该服务.
我尝试了以下步骤:
步骤4的输出
运行事务安装.
开始安装的安装阶段.
请参阅日志文件的内容以获取C:\ Users\myusername\Documents\Visual Studio 2010\Projects\TestService\TestService\obj\x86\Debug\TestService.exe程序集的进度.
该文件位于C:\ Users\myusername\Documents\Visual Studio 2010\Projects\Tes tService\TestService\_dj\x86\Debug\TestService.InstallLog.
安装程序集'C:\ Users\myusername\Documents\Visual Studio 2010\Projects\TestS ervice\TestService\_dj\x86\Debug\TestService.exe'.
受影响的参数是:
logtoconsole =
logfile = C:\ Users\myusername\Documents\Visual Studio 2010\Projects\TestService\T\testService\_dj\x86\Debug\TestService.InstallLog
assemblypath = C:\ Users\myusername\Documents\Visual Studio 2010\Projects\TestServ ice\TestService\obj\x86\Debug\TestService.exe
没有具有RunInstallerAttribute.Yes属性的公共安装程序可以在C:\ Users\myusername\Documents\Visual Studio 2010\Projects\TestService\TestSe rvice\_ obj\x86\Debug\TestService.exe程序集中找到.
安装阶段成功完成,提交阶段正在开始.
请参阅日志文件的内容以获取C:\ Users\myusername\Documents\Visual Studio 2010\Projects\TestService\TestService\obj\x86\Debug\TestService.exe程序集的进度.
该文件位于C:\ Users\myusername\Documents\Visual Studio 2010\Projects\Tes tService\TestService\_dj\x86\Debug\TestService.InstallLog.
提交程序集'C:\ Users\myusername\Documents\Visual Studio 2010\Projects\TestS ervice\TestService\_obj\x86\Debug\TestService.exe'.
受影响的参数是:
logtoconsole = …
我有一个Windows服务可执行文件,我知道是用.NET编写的,我需要在不同的服务名称下安装以避免冲突.无论如何,安装都不提供指定服务名称.如果我只能访问二进制文件,那么当我用installutil安装它时,是否还要覆盖服务名称?
刚尝试通过以下方式运行应用程序:

我浏览了一个带有应用程序的目录WindowsService1.exe,然后尝试了命令,Installutil WindowsService1.exe但得到了以下错误...

由于VS只安装了一两天,我担心安装会出现问题,因为它应该识别installutil.
我是否可以执行一些基本诊断以确保VS命令提示符找到它应该的所有程序?
编辑
如果我PATH在命令提示符下运行,我会看到以下内容:

我创建了一个Windows服务程序,我希望我的错误严格写入Windows eventLog.所以我从代码项目文章中遵循了以下步骤:
http://www.codeproject.com/KB/dotnet/simplewindowsservice.aspx
但是,当我启动或停止服务时,我没有在事件查看器窗口中创建的事件日志中看到任何自定义日志消息.另外,如何指定消息是由于错误还是仅仅是信息?
根据如何创建用户定义的服务,您可以使用 Windows NT 资源工具包创建 Windows 服务。例如如上面链接所示:
C:\Program Files\Resource Kit\Instsrv.exe Notepad C:\Program Files\Resource Kit\Srvany.exe
Run Code Online (Sandbox Code Playgroud)
但这在 Windows 7 或 10 以及 64 位平台上不起作用,因为 Windows NT 资源工具包不适用于较新的 Windows 版本。我能够使用此批处理文件创建 Windows 服务:
sc create "MyService" binPath= "C:\Program Files (x86)\MyProg\myprog.exe" start= auto DisplayName= "My Service" obj= LocalSystem
Run Code Online (Sandbox Code Playgroud)
但它不会启动 Windows 服务。当我尝试启动时,我收到以下消息:

Windows 无法在本地计算机上启动 OrchestrateIT Import Service 服务。
错误1053:服务未及时响应启动或控制请求。
使用 Windows 命令提示符安装 Windows 服务?中的信息 并 从可执行文件创建 Windows 服务不起作用。
如何成功启动Windows服务?
windows-services batch-file command-prompt windows-7 windows-10
c# ×3
service ×2
.net ×1
batch-file ×1
cmd ×1
events ×1
installutil ×1
logging ×1
windows ×1
windows-10 ×1
windows-7 ×1