正确的InstallUtil路径到文件语法?

Mr.*_*ith 11 syntax installutil path batch-file .net-2.0

我正在尝试使用批处理文件安装Windows服务,我们称之为"installservice.bat".在文件中我有以下命令:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe -i ".\MyService.exe"
    pause

当我执行批处理文件(在Vista上以管理员身份运行)时,我得到了这个:

Exception occurred while initializing the installation:
System.IO.FileNotFoundException: Could not load file or assembly 'file:///C:\Win
dows\system32\MyService.exe' or one of its dependencies. The system cannot f
ind the file specified..

实际服务位于C:\ Services\MyService.exe.".\ MyService.exe"部分应该使它正常运行?

小智 9

以防其他人来这里出现此错误...当您运行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
Run Code Online (Sandbox Code Playgroud)

对...

C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe "C:\Users\joeblow\Documents\Visual Studio 2010\Projects\WindowsService1\WindowsService1\bin\Debug\WindowsService1.exe"
Run Code Online (Sandbox Code Playgroud)


xan*_*ont 3

为什么不直接向 InstallUtil 提供完整路径?