2009-08-14 6 views
11

Sto provando ad installare un servizio Windows utilizzando un file batch, chiamiamolo "installservice.bat". All'interno del file che ho i seguenti comandi:Corretto il percorso di installazione nella sintassi del file?

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

Quando ho excute il file batch (in esecuzione come amministratore su Vista) ottengo questo:

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

Il servizio effettivo si trova in C: \ Services \ Servizio.exe. Quale dovrebbe essere la parte ". \ MyService.exe" affinché funzioni correttamente?

risposta

3

Perché non inserire semplicemente il percorso completo InstallUtil?

+0

Grazie mille, non sapeva che avrebbe funzionato. –

+0

in realtà ha funzionato per me. – lstanczyk

0

copia il file bat MyService.exe ed esegui, non avrai alcun errore.

9

Nel caso in cui qualcun altro venga qui per questo errore ... quando si esegue InstallUtil.exe, se il percorso del servizio contiene spazi, racchiuderlo tra virgolette. Sì, questo è ovvio, ma l'errore che ti dà se non lo fai non lo è.

sbagliato ...

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

destra ...

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