Install Windows Service without Visual Studio

There are a couple of standard ways to install a Windows Service.

  1. Create a Setup and Deployment package in Visual Studio
  2. Use InstallUtil.exe from the Visual Studio Development Command prompt with elevated privileges.

Sometimes these options aren’t available.  Either your version of Visual Studio doesn’t have the Setup and Deployment templates, or the host server doesn’t have a full install of Visual Studio.

There is a third option; the standard command prompt.

Install

  1. Move your Windows Service to the host server.  You will need the main EXE file, the EXE.CONFIG file and any third party DLL’s that you referenced that are not already installed in the GAC.  DLL’s that would already be in the GAC would include all of the Windows System DLL’s.
  2. On the host server open a standard command prompt with administrator privileges.
  3. In the command prompt change the directory to the current .NET framework folder.  If you are using .Net 4.0 the path will be %WINDIR%\Microsoft.NET\Framework\v4.0.30319picCom1
  4. Call the InstallUtil.EXE and pass in the fully qualified path to the service .EXE.  The command line would look something like this: “InstallUtil c:\projects\myproject\myproject.exe”
  5. You should receive feedback in the command prompt declaring the service successfully installed.  If so, open the Services window and start your service.  If the service didn’t install successfully check to make sure you have the privileges, there are no typos, and that your service is where you think it is.

Uninstall

If you need to uninstall the service follow steps 2 and 3 above and then call the InstallUtil.exe with the /u switch.  The command line would look something like this: “InstallUtil /u c:\temp\myproject.exe

Special thanks to Jon Cunningham for this tip!

Leave a Reply

Your email address will not be published. Required fields are marked *