Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install windows service using command promt

I am installing a windows service using visual studio command prompt using the following command

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

But I get the following exception

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

Is the command wrong or Am I missing anything else?

like image 229
user1208862 Avatar asked May 01 '12 10:05

user1208862


People also ask

How do I run a Windows service from the command line?

Press Windows + R, type cmd, and hit Enter to open Command Prompt in Windows 10. Then type the Windows Services command line services. msc and hit Enter to open it.


2 Answers

i have the same problem, in this case Service.exe was blocked.

Solution : right-click on the file and open Properties. You may see a message – This file came from another computer and might be blocked to help protect this computer. Click on the Unblock button and then on Apply/OK

like image 82
Saeed Esmaeili Avatar answered Oct 17 '22 02:10

Saeed Esmaeili


File paths with spaces in them must be quoted.

Good

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

Bad

installutil c:\my directory\service1.exe

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

like image 32
Tim M. Avatar answered Oct 17 '22 02:10

Tim M.