Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Correct InstallUtil Path To File Syntax?

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?

like image 849
Mr. Smith Avatar asked Aug 14 '09 07:08

Mr. Smith


2 Answers

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"
like image 170
jason027 Avatar answered Oct 04 '22 17:10

jason027


Why not just feed InstallUtil the full path?

like image 33
xanadont Avatar answered Oct 04 '22 16:10

xanadont