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

发布于 2024-08-02 02:00:40 字数 554 浏览 4 评论 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”部分应该是什么才能正常运行?

I'm trying to install a Windows Service using a batch file, let's call it "installservice.bat". Inside the file I have the following commands:

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

When I excute the batch file (running as administrator on Vista) I get this:

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..

The actual service is located at C:\Services\MyService.exe. What should the ".\MyService.exe" part be for it to function properly?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

╭ゆ眷念 2024-08-09 02:00:41

以防万一其他人出现此错误...当您运行 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"

Just in case someone else comes here for this error... when you run InstallUtil.exe, if the path to your service contains spaces, surround it with quotes. Yes this is obvious, but the error it gives you if you don't is not.

wrong...

C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe C:\Users\joeblow\Documents\Visual Studio 2010\Projects\WindowsService1\WindowsService1\bin\Debug\WindowsService1.exe

right...

C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe "C:\Users\joeblow\Documents\Visual Studio 2010\Projects\WindowsService1\WindowsService1\bin\Debug\WindowsService1.exe"
铁憨憨 2024-08-09 02:00:41

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

Why not just feed InstallUtil the full path?

攒眉千度 2024-08-09 02:00:41

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

copy the bat file MyService.exe folder and execute, you wont get any error.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文