Click here to Skip to main content
15,880,796 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
I have created Windows Service in Visual Studio 2015 (Professional), .NET version: 4.5.2
But I am not able to install this windows service on my machine.

Followed below mentioned steps to install Windows Service

1. Start >> All Programs >> Visual Studio 2015 >> Visual Studio Tools >> Right Click "Developer Command Prompt for VS2015" and click "Run as administrator"

2. In VS 2015 Command Prompt, typed location of windows service. I.e. "CD C:\Sandbox\WindowServices\MyNewService\MyNewService\bin\Debug"

3. Typed >> InstallUtil.exe “MyNewService.exe” command

Step 3 is supposed to install Windows Service, but, instead I get error "'InstallUtil.exe' is not recognized as an internal or external command,
operable program or batch file.
"

---------------------------- More Info ------------------
Local machine configuration:
OS: Windows 7 Enterprise
System Type: 64 bit
-----
Location of InstallUtil.exe: C:\Windows\Microsoft.NET\Framework\v4.0.30319


Seeking for help on urgent basis.

Thanks in advance

What I have tried:

1. Initially windows service was at D Drive, moved it to C drive, still same error
2. Moved Windows service exe to InstallUtil location and both CD command for util location and InstallUtil.exe “MyNewService.exe”, but get error "file not found" for the window service exe
3. Tried to install window service through a batch file found through google, it gives same error as "File Not Found"
4. Searched other options on Google, but nothing seems specific to my problem.

Note: When I open VS2015 Command Prompt it shows "ERROR: Cannot determine the location of the VS Common Tools folder." Is this culprit in my case? If so how to solve this error in command prompt.
Posted
Updated 10-Oct-19 2:19am

You should first navigate to the path where InstallUtil.exe is present on your system and then run the commands.

For you the file is presnet under C:\Windows\Microsoft.NET\Framework\v4.0.30319

So open command prompt as administrator and then type
cd C:\Windows\Microsoft.NET\Framework\v4.0.30319

From there you can use
JavaScript
'InstallUtil.exe MyNewService.exe'
 
Share this answer
 
Comments
sopy7 7-Sep-16 6:55am    
@NaibedyaKar: You are almost correct,
Typing "cd C:\Windows\Microsoft.NET\Framework\v4.0.30319" will give access to InstallUtil.exe location.
But typing 'InstallUtil.exe MyNewService.exe' will give "File Not Found" error.
Instead will have to type entire path of windows service after installUtil.exe command. I.e. Executing below two lines successfully installs windows service on my machine

1. cd C:\Windows\Microsoft.NET\Framework\v4.0.30319
2. InstallUtil.exe C:\Sandbox\Window
Services\MyNewService\MyNewService\bin\Debug\MyNewService.exe
Kamal Anass 28-May-17 10:50am    
Exception occurred while initializing the installation:
System.IO.FileNotFoundException: Could not load file or assembly 'file:///C:\Users\anass\OneDrive\Documents\visual' or one of its dependencies. The system cannot find the file specified..
NaibedyaKar 7-Sep-16 7:12am    
yes, you will have to provide the entire path for your exe. Else how it will know the path :).

Glad that it worked for you.
sopy7 8-Sep-16 2:11am    
Thanks for your help.
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

then try to install service again
 
Share this answer
 
Comments
Richard Deeming 5-Sep-18 12:41pm    
If that was the problem, you wouldn't get the error message that was clearly mentioned in the question title. You seem to be replying to the comment from Kamal Anass, rather than the original question.

If you read the comments to solution 1, you'll see that the problem has already been solved.
Steps for Installing the InstallUtil.exe

1. Start >> All Programs >> Visual Studio 2015 >> Visual Studio Tools >> Right Click "Developer Command Prompt for VS2015" and click "Run as administrator"

2. In VS 2015 Command Prompt, typed the location of .Net FrameWork. I.e. "CD C:\Windows\Microsoft.NET\Framework\v4.0.30319"

3. InstallUtil.exe "E:\MyNewService\MyNewService\bin\Debug\MyNewService.exe"
 
Share this answer
 
Comments
CHill60 20-Jun-19 3:54am    
Already detailed in Solution 1 + the comments to that solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900