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

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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s