代码之家  ›  专栏  ›  技术社区  ›  Mr. Smith

文件语法的InstallUtil路径是否正确?

  •  11
  • Mr. Smith  · 技术社区  · 15 年前

    我正在尝试使用批处理文件安装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”部分应该是什么才能正常工作?

    3 回复  |  直到 15 年前
        1
  •  9
  •   Luke Willis Will    11 年前

    以防万一有人因为这个错误而来。。。运行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"
    
        2
  •  3
  •   xanadont    15 年前

    为什么不直接输入完整路径?

        3
  •  0
  •   Meraj    13 年前

    复制bat文件MyService.exe文件夹并执行,不会出现任何错误。