Windows XP/Vista/7: Run program as a service

Open up a command prompt in Admin mode and type in the following command.

If any of the paths include spaces, you have to use (escaped) quotes around the path, like this:

sc create subversion binpath= "\"C:\Program Files\Subversion\bin\svnserve.exe\" --service --root C:\ServerFiles\svn_repository" displayname= "Subversion" depend= tcpip start= auto

A simplified pseudo version of the call is:

sc create shortname binpath= "\"C:\Path\To\Your\program.exe\" --your-program-options" displayname= "Full Name of Service for Service Manager" start= auto

A breakdown of the command arguments is shown below. Strangely enough, the space after the = sign is required.

  • "sc create subversion"
    Creates a service named "subversion".
  • "binpath= "
    The executable file.
  • "--service"
    (Argument to SVN) Run it within the Windows native service wrapper. Shows how you can pass arguments to the executable.
  • "--root= "
    (Argument to SVN) The root folder for repositories. Also shows how you can send arguments to the executable.
  • "displayname= "
    A nice name for the service in the Service Manager.
  • "depend= "
    Dependencies for this service.
  • "start= "
    The starting method.

For more information, see the Microsoft's KB251192.

If you typed something wrong, type "sc delete subversion" to delete the service and start again.

Once created, type "net start subversion" to start it.

Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog