By Vikash Pandey

2011-11-17 09:32:07 8 Comments

I want to install a Windows service using a Windows command prompt (not the Visual Studio command prompt).

How do I do this?


@Arvind Chourasiya 2020-03-11 06:12:34

open Developer command prompt as Admin and navigate to

cd C:\Windows\Microsoft.NET\Framework\v4.0.30319

Now use path where is your .exe there

InstallUtil "D:\backup\WindowsService\WindowsService1\WindowsService1\obj\Debug\TestService.exe"

@MKR 2017-12-15 12:29:20

I must add one more point in this thread. To install/uninstall 64-bit version of assemblies one should use 64-bit version of tool. To install a service, the command should be:


and to uninstall the command should be:

"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe" -u

@AMIR2580 2019-12-13 12:29:44

1.From the Start menu, select the Visual Studio directory, then select Developer Command Prompt for VS .

2.The Developer Command Prompt for Visual Studio appears.

3.Access the directory where your project's compiled executable file is located.

4.Run InstallUtil.exe from the command prompt with your project's executable as a parameter

@Sid 2017-10-30 01:26:02

Nothing wrong with SC Create command. Just you need to know the correct args :

SC CREATE "MySVC" binpath= "D:\Me\Services\MySVC\MySVC.exe"

@Alejandro 2017-11-01 13:21:00

This is the only answer that references the official way to install/modify/delete a service. Moreover, this doesn't depends on the .NET Framework being installed and works with any kind of file, not just .NET binaries.

@Sid 2017-12-22 08:32:50

Yep..thats why i loved this approach and always advice it since all the work needs to be done into the exe which can belong to any .net fw version.

@Paramvir Singh Karwal 2019-09-27 08:18:49

why does it give me ` A positional parameter cannot be found that accepts argument 'binpath='. `

@Captain Dashenka 2019-10-07 13:02:26

worth noting that this command is only available for windows server ( and some older windows versions ). Win 10 has an sc command also but it's something different, can't be used to register services.

@Urk 2019-10-07 15:30:38

Note that the space after "binpath= " is imperative. @ParamvirSinghKarwal

@lmsm3 2019-12-26 19:31:49

Is there any downside to this vs using InstallUtil?

@Matthew 2020-02-05 02:50:33

SC CREATE is handy as you can specify a different service name than might be configured in the program. Handy when you want to install the same program as different services. See here…

@Jesper Riemer Andersen 2020-02-10 13:38:29

If using powershell to run this command note that SC is an alias for Set-Content. Writing SC.exe will fix that.

@Danish Sulaiman 2019-09-29 07:33:01

Open command prompt as administrator, go to your Folder where your .exe resides. To Install Exe as service

D:\YourFolderName\YourExeName /i

To uninstall use /u.

@Hamit YILDIRIM 2019-07-05 22:42:08

Fallow the steps when deploying the Windows Service, don't lost time

1- Run command prompt by the Admin right

2- Insure about release mode when compilling in your IDE

3- Give a type to your project installer on design view

4- Select authentication type in accordance the case

5- Insure about software dependencies: If you are using a certificate install it correctly

6- Go your console write this:

C:\Windows\Microsoft.NET\Framework\yourRecentVersion\installutil.exe c:\yourservice.exe

there is a hidden -i argument before the exe path -i c:\ you can use -u for uninstallling

7- Look your .exe path to seem log file. You can use event viewer to observing in the feature

@Pawel Wujczyk 2018-02-15 19:26:14

If you are using Powershell and you want to install .NET service you can use Install-Service module. It is a wrapper for InstalUtil tool.

It exposes 3 commands

  • Install-Service - invokesĀ InstallUtil.exe pathToExecutable command
  • Install-ServiceIfNotInstalled - first it checks if service is installed if not perform the method Install-Service
  • Uninstall-Service- it uninstalls service. ServiceName of path to executable can be used.

Code to this module can be viewed here

@Kaushik AppzyTech 2017-11-01 12:52:18

Install Service:-


UnInstall Sevice:-

"C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe" -u "C:\Services\myservice.Service.exe"

@saber tabatabaee yazdi 2017-04-05 12:31:56

when your assembly version and your Visual studio project Biuld setting on dot net 2 or 4 install with same version.

install service with installutil that same version

if build in dot net 4

Type c:\windows\\framework\v4.0.30319\installutil.exe

if build in dot net 2

Type c:\windows\\framework\v2.0.11319\installutil.exe

@Joji Thomas Eapen 2018-09-16 07:23:57

the following code , install and uninstall the Service,

Open the command prompt and run the program as an administrator and fire the below command and press enter.


To Install

C:\windows\\framework\v4.0.30319>InstallUtil.exe + Your copied path + \your service name + .exe

eg :Our Path InstallUtil.exe C:\MyFirstService\bin\Debug\MyFirstService.exe

To uninstall

 C:\windows\\framework\v4.0.30319>InstallUtil.exe -u + Your copied path + \your service name + .exe

eg : Our path InstallUtil.exe -u C:\MyFirstService\bin\Debug\MyFirstService.exe

for more help you can see the following link: sample program

@Base33 2012-07-26 00:29:04

Perform the following:

  1. Start up the command prompt (CMD) with administrator rights.
  2. Type c:\windows\\framework\v4.0.30319\installutil.exe [your windows service path to exe]
  3. Press return and that's that!

It's important to open with administrator rights otherwise you may find errors that come up that don't make sense. If you get any, check you've opened it with admin rights first!

To open with admin rights, right click 'Command Prompt' and select 'Run as administrator'.


@Karan Raiyani 2018-08-10 14:03:40

Open Visual studio and select new project by selecting Windows Service template in Windows Desktop tab. Than copy following code into your service_name.cs file.

using System.Diagnostics;
using System.ServiceProcess;
namespace TimerService
    public partial class Timer_Service : ServiceBase
        public Timer_Service()
        static void Main()
            if (System.Diagnostics.Debugger.IsAttached)
                Timer_Service service = new Timer_Service();
                ServiceBase[] ServicesToRun;
                ServicesToRun = new ServiceBase[]
                    new Timer_Service()
        protected override void OnStart(string[] args)
            EventLog.WriteEvent("Timer_Service", new EventInstance(0, 0, EventLogEntryType.Information), new string[] { "Service start successfully." });
        protected override void OnStop()
            EventLog.WriteEvent("Timer_Service", new EventInstance(0, 0, EventLogEntryType.Information), new string[] { "Service stop successfully." });

Right-Click on service_name.cs file and open designer of service. than right-click and select Add Installer. than right-click on serviceProcessInstaller1 and change its property value of Account from User to Local System.

Remove static void main method from Program.cs file. Than save and Build your project.

NOTE: goto bin\Ddebug folder of your project folder. Than open Properties of your service_name.exe file. Than goto Compatibility tab. Than click on Change Settings For All Users.

Select option Run this program as an administrator.

Now, You have to open CommandPromt as Administrator. After open, set directory to where your InstallUtil.exe file is placed. for ex: C:\Windows\Microsoft.NET\Framework64\v4.0.30319. now write the following command:

C:\Windows\Microsoft.NET\Framework64\v4.0.30319>InstallUtil.exe -i C:\TimerService\TimerService\bin\Debug\TimerService.exe

Note: -i is for install he service and -u for Unsinstall.

after -i set the write the path where you want to install your service.

now write the command in CommandPromt as follows:

C:\TimerService\TimerService\bin\Debug>net start service_name

Note: use stop for stop the Service.

Now, open ViewEventLog.exe. Select Windows Logs>Application. There you can check your Service's log by start and stop the service.

@Mohammad Dayyan 2018-07-07 11:54:47

Create a *.bat file beside of your windows service exe file for installing with the following context:

ECHO Installing My Windows Service 

START %windir%\Microsoft.NET\Framework\v4.0.30319\installutil.exe "%~d0%~p0\YourWindowsServiceExeName.exe"

Create a *.bat file beside of your windows service exe file for uninstalling with the following context:

ECHO Uninstalling My Windows Service 

START %windir%\Microsoft.NET\Framework\v4.0.30319\installutil.exe -u "%~d0%~p0\YourWindowsServiceExeName.exe"

Run each of bat file as Admin to install or uninstall your windows service.

@Soft-Web Expert 2018-05-02 18:19:24

You should open command prompt, go to

C:\windows\\framework\v4.0.30319\InstallUtil.exe -i ".EXE file of window service"

@Oguzhan KIRCALI 2017-10-17 06:56:49

  1. Run Windows Command Prompt as Administrator
  2. paste this code: cd C:\Windows\Microsoft.NET\Framework\v4.0.30319\ to go to folder
  3. edit and run this too: installutil C:\ProjectFolder\bin\Debug\MyProject.exe

Note: To uninstall: installutil /u C:\ProjectFolder\bin\Debug\MyProject.exe

@what server 2017-04-14 10:08:37

  1. start up the command prompt (CMD) with administrator rights.
  2. Type c:\windows\\framework\v4.0.30319\installutil.exe [your windows service path to exe]
  3. Press return

@Dhanuka777 2014-03-13 08:34:57

If the directory's name has a space like c:\program files\abc 123, then you must use double quotes around the path.

installutil.exe "c:\program files\abc 123\myservice.exe"

Install windows service from command prompt

It makes things much easier if you set up a bat file like following,

e.g. To install a service, create a "myserviceinstaller.bat" and "Run as Administrator"

@echo off
cd C:\Windows\Microsoft.NET\Framework\v4.0.30319
installutil.exe "C:\Services\myservice.exe"

if ERRORLEVEL 1 goto error
echo There was a problem

to uninstall service,

Just add a -u to the installutil command.

cd C:\Windows\Microsoft.NET\Framework\v4.0.30319

C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe -u "C:\Services\myservice.exe"

@hcb 2011-11-17 09:52:12

Navigate to the installutil.exe in your .net folder (for .net 4 it's C:\Windows\Microsoft.NET\Framework\v4.0.30319 for example) and use it to install your service, like this:

"C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe" "c:\myservice.exe"

@nme 2016-02-23 10:10:20

If it is the x64 compiled service, use "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\installutil‌​.exe".

@Nick 2016-03-22 14:39:07

I get a weird error. No public installer with the RunInstallerAttribute. Yes attribute could be found in the .exe assembly. Remove InstallState file because there are no installers

@ShaileshDev 2017-01-05 13:59:00

Hi, I tried this solution but its giving exception as "...file not found or one of its dependencies." Please help.

@Cataklysim 2017-07-11 12:01:30

For everyone with the same problem as all these and me: You dont need to put the whole path in it anymore. a simple installutil.exe "C:\YourProject.exe" is enough.

@Robin French 2017-09-21 16:09:12

Is there any difference between installutil in 'Framework' and 'Framework64'?

@BluE 2018-08-08 14:14:30

@Cataklysim You do have to use the full path, unless you added it to the path environment variable.

@Shriram Navaratnalingam 2019-11-18 08:18:39

Similarly to uninstall we can use "/u" as additional flag, for an example: "C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.e‌​xe" /u "c:\myservice.exe"

@lmsm3 2019-12-26 19:34:54

Does this depend on the service exe staying where it has been installed, or can it been removed after installing it like this?

Related Questions

Sponsored Content

43 Answered Questions

[SOLVED] How do I create an Excel (.XLS and .XLSX) file in C# without installing Microsoft Office?

  • 2008-09-29 22:30:28
  • mistrmark
  • 1095468 View
  • 1891 Score
  • 43 Answer
  • Tags:   c# .net excel file-io

16 Answered Questions

[SOLVED] Aliases in Windows command prompt

25 Answered Questions

37 Answered Questions

[SOLVED] Error - Unable to access the IIS metabase

13 Answered Questions

[SOLVED] How can I delete a service in Windows?

21 Answered Questions

[SOLVED] How to solve "The specified service has been marked for deletion" error

  • 2013-12-13 08:20:42
  • Arseni Mourzenko
  • 483736 View
  • 582 Score
  • 21 Answer
  • Tags:   windows-services

13 Answered Questions

[SOLVED] Run Command Prompt Commands

5 Answered Questions

7 Answered Questions

[SOLVED] Install Windows Service created in Visual Studio

13 Answered Questions

[SOLVED] How do I uninstall a Windows service if the files do not exist anymore?

Sponsored Content