Install a Windows service using the promt command

I install a windows service using the visual studio command command using the following command

installutil D:\Folder1\Projectname\bin\Debug\Service1.exe 

But I get the following exception

An exception occurred during initialization installation: System.IO.FileNotFoundException: Could not load file or assembly 'file: /// D: \ Folder1 \ WIN' or one of its dependencies. The system cannot find the specified file.

Is the command incorrect or am I missing something?

+6
source share
4 answers

File paths with spaces in them should be indicated.

Good

 installutil "c:\my directory\service1.exe" 

poorly

 installutil c:\my directory\service1.exe 

The OS stops reading the path in the first space, forcing it to look for a file named "c: \ my" that does not exist.

+19
source

To avoid such errors, follow these steps:

  • Run a command prompt called "As Administrator"
  • Change the command line directory to your service exe file.

After that do

 command> installutil service1.exe 
0
source

Lack of quotes was a problem. Installutil "exe / d path"

0
source

1) Run the developer command line command as administrator mode. 2) and make below changes

 installutil -i "D:\Folder1\Projectname\bin\Debug\Service1.exe" 
0
source

Source: https://habr.com/ru/post/914616/


All Articles