Adoptable Cookbooks List

Looking for a cookbook to adopt? You can now see a list of cookbooks available for adoption!
List of Adoptable Cookbooks

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.

Select Badges

Select Supported Platforms


nssm (11) Versions 2.0.0

Installs/Configures NSSM

cookbook 'nssm', '= 2.0.0'
cookbook 'nssm', '= 2.0.0', :supermarket
knife cookbook site install nssm
knife cookbook site download nssm

NSSM Cookbook

Cookbook Version Build Status

This cookbook installs the Non-Sucking Service Manager (, and exposes resources to install and remove Windows services.


  • Chef 12.6+


  • Windows


Add recipe[nssm] to run list.

Quick Start

To install a Windows service:

nssm 'service name' do
  program 'C:\Windows\System32\java.exe'
  args '-jar C:/path/to/my-executable.jar'
  action :install

To remove a Windows service:

nssm 'service name' do
  action :remove

Using Parameters

A parameter is a hash key representing the same name as the registry entry which controls the associated functionality. So, for example, the following sets the Startup directory, I/O redirection, and File rotation for a service:

nssm 'service name' do
  program 'C:\Windows\System32\java.exe'
  args '-jar C:/path/to/my-executable.jar'
    AppDirectory: 'C:/path/to',
    AppStdout: 'C:/path/to/log/service.log',
    AppStderr: 'C:/path/to/log/error.log',
    AppRotateFiles: 1
  action :install

Arguments with Spaces

Having spaces in servicename, program and params attributes is not a problem, but spaces in an argument is a different matter.

When dealing with an argument containing spaces, surround it with 3 double quotes:

nssm 'service name' do
  program 'C:\Program Files\Java\jdk1.7.0_67\bin\java.exe'
  args '-jar """C:/path/with spaces to/my-executable.jar"""'
  action :install

When dealing with arguments requiring interpolation and it contains one or more arguments with spaces, then encapsulate the args string using %() notation and use """ around arguments with spaces:

my_path_with_spaces = 'C:/path/with spaces to/my-executable.jar'
nssm 'service name' do
  program 'C:\Program Files\Java\jdk1.7.0_67\bin\java.exe'
  args %(-jar """#{my_path_with_spaces}""")
  action :install


  • node['nssm']['src'] - This can either be a URI or a local path to nssm zip.
  • node['nssm']['sha256'] - SHA-256 checksum of the file. Chef will not download it if the local file matches the checksum.



  • install - Install a Windows service.
  • remove - Remove Windows service.

Attribute Parameters

  • servicename - Name attribute. The name of the Windows service.
  • program - The program to be run as a service.
  • args - String of arguments for the program. Optional
  • params - Hash of key value pairs where key represents associated registry entry. Optional
  • start - Start service after installing. Default` - true

ChefSpec Matchers

The NSSM cookbook includes custom ChefSpec matchers you can use to test your own cookbooks that consume Windows cookbook LWRPs.

Example Matcher Usage

expect(chef_run).to install_nssm('service name').with(
  :program 'C:\Windows\System32\java.exe'
  :args '-jar C:/path/to/my-executable.jar'    

NSSM Cookbook Matchers

  • install_nssm(servicename)
  • remove_nssm(servicename)

Getting Help


Please refer to CONTRIBUTING.


MIT - see the accompanying LICENSE file for details.


2.0.0 2016-10-03

  • Drop support for Chef 11

1.2.1 2016-04-12

  • Include default recipe in provide only if required

1.2.0 2015-08-09

  • Use new install_location attribute everywhere
  • Don't try to install nssm if it's already there

1.1.0 2015-02-06

  • Add an attribute for the install location of nssm.exe

1.0.0 2014-12-17

  • Remove deprecated matchers
  • Ensure nssm is being installed before service is installed

0.2.0 2014-10-08

  • Chef cache path no longer hard coded
  • Chefspec matchers comply with naming convention

0.1.0 2014-09-21

  • Initial release using nssm v2.24

Collaborator Number Metric

2.0.0 failed this metric

Failure: Cookbook has 0 collaborators. A cookbook must have at least 2 collaborators to pass this metric.

Foodcritic Metric

2.0.0 passed this metric