Pergunta

Eu estou tentando instalar um serviço do Windows usando um arquivo de lote, vamos chamá-lo "installservice.bat". Dentro do arquivo Eu tenho os seguintes comandos:

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

Quando eu excute o arquivo de lote (em execução como administrador no Vista) fico com esta:

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

O serviço real está localizada em C: \ Services \ MyService.exe. Qual deveria ser a parte "\ MyService.exe" ser para que ela funcione corretamente?

Foi útil?

Solução

Por que não apenas alimentar InstallUtil o caminho completo?

Outras dicas

Apenas no caso de alguém vem aqui para este erro ... quando você executar InstallUtil.exe, se o caminho para o seu serviço contiver espaços, coloque-a entre aspas. Sim, isso é óbvio, mas o erro dá-lhe se não o fizer não é.

errado ...

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

certo ...

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

copiar a pasta MyService.exe bat e executar, você não vai obter qualquer erro.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top