Visual Studio Developer Center > Visual C# Forums > Visual C# General > How to Install Windows Service using command prompt

Answered How to Install Windows Service using command prompt

  • Monday, May 15, 2006 12:08 PM
     
     

    Hello all,

    I want to install the windows service using DOS Prompt(not Visual Studio command prompt).

    How to do this?

    plz help me will be appriciated

Answers

  • Monday, May 15, 2006 1:30 PM
     
     Answered

    Hi

    Sorry for the confusion, you still need to invoke installutil in order to install your service, there's no other way to do this if you dont have the .Net Framework runnig on your machine. The alturnatives if you are using normal CMD are :-

    1. On VS 2003 :- C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\InstallUtil.exe C:\MyService.exe

    2 On VS 2005 Express :- C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe C:\MyService.exe

    Hope this Helps

All Replies

  • Monday, May 15, 2006 12:19 PM
     
     

    hi

    In VStudio command prompt run :- installutil <Path of the Service> (e.g installutil C:\MyService.exe)

    Im not sure if normal DOS cmd can do this.

    Hope this helps.

  • Monday, May 15, 2006 12:39 PM
     
     

    plz read once again my question.

    I want to install windowsService from command Prompt.

    Not from VisualStudioCommandPrompt.

     

    How to do this?

     

     

  • Monday, May 15, 2006 1:30 PM
     
     Answered

    Hi

    Sorry for the confusion, you still need to invoke installutil in order to install your service, there's no other way to do this if you dont have the .Net Framework runnig on your machine. The alturnatives if you are using normal CMD are :-

    1. On VS 2003 :- C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\InstallUtil.exe C:\MyService.exe

    2 On VS 2005 Express :- C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe C:\MyService.exe

    Hope this Helps

  • Monday, March 17, 2008 7:26 AM
     
     

     

    Hi,

     

    I have tried the above steps, but the problem is that I am having Windows XP and it doesnot recognize InstallUtil via command prompt. Is there any alternative command which I can use instead of InstallUtil.

     

    Thanks & Regards,

    Amit H

  • Monday, March 17, 2008 9:03 AM
     
     
    Hi Amit

    You need to have atleast the .Net Framework installed ( i guess your service is .net and hence would need it anycase rt)
    After that go to your .Net framework folder under windows directory and run the installUtil application to register the service.

    Thanks n Regards
    Anu Viswan
  • Tuesday, June 03, 2008 9:10 AM
     
     
    Hi All,

    Check if .NET framework 2.0 is installed. u can find the folder C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 folder. Just use the installutil.exe utility from this folder and install the service.

    Regards,
    Sayeed
  • Tuesday, June 03, 2008 9:22 AM
     
     Proposed Answer
    Hello Ramana,

    I can understand your problem..
    InstallUtil is a Visual Studio command and so it wont recognise in the command prompt in Windows XP since a path to it has not been set..
    So you have to set a path for this command so that windows may recognise it...

    Try these steps:
    1. Right Click 'My Computer' in your desktop.
    2. goto Properties -> Advanced -> Environment Variables
    3. Find the 'Path' variable in system variables and click EDIT.
    4. Add this path C:\Program Files\Microsoft Visual Studio 9.0\VC\; to you existing path.
    5. Restart cmd and type installutil at command prompt. If it works correctly, some text would scroll up in the command window.

    Remember you need to append this path to the existing path variable. This means that if a semicolon is not there at the end of the existing path, dont forget to first type a semi colon ';' and then add the path in step 4.

    If .NET is installed in some other drive, give the appropriate path..

    Hope this helps !!
    Always mark the post that helped you as "Answer". That helps future users to locate answers quickly.
    • Proposed As Answer by Somnath Paul Tuesday, June 03, 2008 9:22 AM
    •  
  • Thursday, August 14, 2008 9:56 AM
     
     
    thank you for giving the path, this helpe me very much
  • Wednesday, July 29, 2009 9:06 AM
     
     
    Hi friend,

    I have implemented as you said and it works for me very nice.

    But friend i want to install windows service for .net framework 3.5 so from where i can run?

    I have windows service exe making in .net 3.5. now i want to install this so how can it possible?

    Thanks & Regards
  • Wednesday, July 29, 2009 3:52 PM
     
     
    Hi All,

    I had used all the above methods to install a windows service using installutil.exe. I tried both in Visual Studio command prompt as well as Windows cmd (by the appropriate ways specifies above).
    In VS Command Prompt i am using the command : C:\folder pathname-----\installutil.exe bin\MyService.exe
    But, i am continuously getting the same error all the time : Exception occurred while initializing the installation:System.IO.FileNotFoundException:Could not load file or assembly "path of the file----/installutil.exe bin\MyService.exe" or one of its dependencies. The system could not find the file specified..

    Though i could see that the MyService.exe file is well created in the bin/Debug folder in my solution folder.

    I dont know what is going wrong here...Can anybody please help?

    Thanks and regards,

    Abhinav
  • Wednesday, July 29, 2009 4:02 PM
     
     
    If in the VS command prompt, I type down : "C:\ ---pathname---\ installutil.exe Myservice.exe " , It tries to install the service but fails everytime. It says "The installation failed, and the Rollback has been performed." I dont know how to proceed with this...help needed..!
  • Thursday, August 06, 2009 3:29 PM
     
     
    you need to go to the corresponding folder for the version of .net in "C:\WINDOWS\Microsoft.Net\Framework\" in command prompt

    I believe for .net 3.5 you need to use "AddInUtil.exe"

    And then run that followed by C:\--Path-to-serverice.exe--\service.exe and that should work....
  • Thursday, August 06, 2009 4:59 PM
     
     

    Hello Ramana!

    Please check this way (http://www.liberidu.com/blog/?p=304).

    Best wishes,
      Vladimir.


    Scio me nihil scire
  • Tuesday, August 18, 2009 8:19 PM
     
     

    Hi Abhinav,


    I hope you have the .Net Framework 2.0 installed on your machine.
    When you are running installUtil.exe from the VS Command prompt please use the full path for your  exe file that you have craeted eg.

    c:\Program Files\Microsoft Visual Studio 9.0\VC>InstallUtil  c:\Application Folder\Bin\Release\FileName.exe


    This should work.
    FYI :
     Use installUtil /u  to unistall the service


    Thanks
    vijay

  • Friday, October 09, 2009 2:19 PM
     
     Proposed Answer
    Simple. Once upon a time, before .NET this was done manually. Luckilly, Windows still supports this process.

    Open a command prompt and execute    SC /?.

    This is the command line application for managing the NT Service Controller.
    Gary in Massena
    • Proposed As Answer by GTNovosel Friday, October 09, 2009 2:20 PM
    •  
  • Sunday, April 18, 2010 5:01 PM
     
     
    There is no difference b/w the VisualStudioCommandPrompt and cmd except the evironment variables and the default working directory.
    Vibhor Agarwal
  • Friday, June 18, 2010 7:53 PM
     
     

    Abhi......Need to provide the full path.

    Example

    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>installutil C:\YourProject\bin\YourExeFile.exe

  • Friday, June 18, 2010 7:55 PM
     
     

    Explanation cannot be any more simpler than suggested by BullDog.

  • Wednesday, July 28, 2010 12:14 AM
     
     

    you can find installutil.exe only in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727.

    I am unable to find that in other versions. Any way your post is helpful man...thanks.

  • Saturday, August 21, 2010 12:06 PM
     
     

    Hi Ramana

     

    I don't know why guys are complicating life for you... just go to command prompt and use servicename.exe /install

    Example:

    C:\Documents and Settings\igachugu>e:

    E:\>cd timer

    E:\Timer>Cyberman.exe /install  (This installs the windows service Cyberman.exe and gives a confirmation)



    E:\Timer>Cyberman.exe /uninstall (This removes the service)

    E:\Timer>

     

    Let me know if it works.

     

  • Friday, January 28, 2011 1:12 AM
     
     

    To install windows service using Command Prompt, you should set the Variable Environment to the path where installutil saved, so the command prompt  so the command prompt will recognized the 'Installutil'.

    How to set the windows Variable environment you can refer to this link


    Regards, Christofel
  • Sunday, February 27, 2011 7:13 AM
     
     
    Below link provide a clean and crisp solution for the above problem
    http://www.a2zmenu.com/Blogs/CSharp/Using-InstallUtil-to-install-uninstall-service.aspx
  • Wednesday, April 13, 2011 11:04 AM
     
     
  • Thursday, October 06, 2011 8:42 AM
     
     
    Apologies, though it is silly, if you can't find it why don't you search for it? :) No offence mate.