2009-08-14 3 views
11

バッチファイルを使用してWindowsサービスをインストールしようとしていますが、これを "installservice.bat"としましょう。私は、次のコマンドを持っているファイルの中に:私は、バッチファイル(Vistaで管理者として実行されている)をexcuteときInstallUtilパスのファイル構文を修正しますか?

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

私はこれを取得:

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に位置しています:\サービス\ MyService.exe。 「。\ MyService.exe」部分が正しく機能するにはどうすればよいでしょうか?

答えて

3

InstallUtilにフルパスを入力するだけではどうですか?

+0

どうもありがとう、それが働くだろう知りませんでした。 –

+0

それは実際に私のために働いた。 – lstanczyk

0

batファイルの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 

右...

C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe "C:\Users\joeblow\Documents\Visual Studio 2010\Projects\WindowsService1\WindowsService1\bin\Debug\WindowsService1.exe" 
関連する問題