Correct InstallUtil Path To File Syntax?
Asked Answered
T

3

11

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?

Teak answered 14/8, 2009 at 7:53 Comment(0)
F
3

Why not just feed InstallUtil the full path?

Flimsy answered 14/8, 2009 at 8:1 Comment(0)
H
10

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"
Histaminase answered 9/3, 2012 at 18:6 Comment(0)
F
3

Why not just feed InstallUtil the full path?

Flimsy answered 14/8, 2009 at 8:1 Comment(0)
O
0

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

Outsize answered 14/10, 2011 at 11:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.