我正在尝试使用批处理文件安装Windows服务,我们称之为“installservice.bat”。在文件中我有以下命令:
C:\ WINDOWS \ Microsoft.NET \ Framework \ v2.0.50727 \ InstallUtil.exe -i“。\ MyService.exe”
暂停
当我执行批处理文件(在Vista上以管理员身份运行)时,我得到了这个:
初始化安装时发生异常:
System.IO.FileNotFoundException:无法加载文件或程序集'file:/// C:\ Win
dows \ system32 \ MyService.exe'或其依赖项之一。系统不能f
ind指定的文件..
实际服务位于C:\ Services \ MyService.exe。 “。\ MyService.exe”部分应该使它正常运行?
为什么不直接提供InstallUtil的完整路径?
为什么不直接提供InstallUtil的完整路径?
以防其他人来这里出现此错误...当您运行InstallUtil.exe时, 如果服务的路径包含空格,请用引号括起来。 是的,这是显而易见的,但如果你不这样做,那么它给你的错误。
错误...
C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe C:\Users\joeblow\Documents\Visual Studio 2010\Projects\WindowsService1\WindowsService1\bin\Debug\WindowsService1.exe
对...
C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe "C:\Users\joeblow\Documents\Visual Studio 2010\Projects\WindowsService1\WindowsService1\bin\Debug\WindowsService1.exe"
复制bat文件MyService.exe文件夹并执行,你不会得到任何错误。