# How to create a service on a windows 10 machine?

**URL:** <https://forum.ansible.com/t/how-to-create-a-service-on-a-windows-10-machine/21109>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [April 8, 2016, 2:05pm UTC](https://forum.ansible.com/t/how-to-create-a-service-on-a-windows-10-machine/21109 "2016-04-08T14:05:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mick\_st\_john](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@Mick\_st\_john](https://forum.ansible.com/u/Mick_st_john)\
**Post date:** [April 8, 2016, 2:05pm UTC](https://forum.ansible.com/t/how-to-create-a-service-on-a-windows-10-machine/21109/1 "2016-04-08T14:05:15Z")

</div>

I am trying to create a service of type kernel on a remote windows 10 machine from a linux ansible controller machine. To create a service I’m using **sc create**  **type=kernel binpath=c:\path** command.

Ansible playbook for creating a service:

- hosts: windows  
tasks:
- name: Create temp service  
raw: sc create temp type=kernel binpath=c:\path\

And I’m getting the following error:

TASK [Create temp service on windows] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [10.x.x.x]: FAILED! =\> {“changed”: false, “failed”: true, “rc”: 1, “stderr”: “#\< CLIXML\r\n\<Objs Version="1.1.0.1" xmlns="[[http://schemas.microsoft.com/powershell/2004/04\](http://schemas.microsoft.com/powershell/2004/04%5C)]([http://schemas.microsoft.com/powershell/2004/04/](http://schemas.microsoft.com/powershell/2004/04/))”\>\<Obj S="progress" RefId="0"\>\<TN RefId="0"\>System.Management.Automation.PSCustomObjectSystem.Object\<I64 N="SourceId"\>1\<PR N="Record"\>Preparing modules for first use.0-1-1Completed-1 \<S S="Error"\>Set-Content : A positional parameter cannot be found that accepts argument ‘type=kernel’._x000D\_\_x000A_\<S S="Error"\>At line:1 char:1\_x000D\_\_x000A\_\<S S="Error"\>+ sc create temp type=kernel binpath=c:\windows\ …_x000D\_\_x000A_\<S S="Error"\>+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ _x000D\_\_x000A_\<S S="Error"\> + CategoryInfo : InvalidArgument: (🙂 [Set-Content], ParameterBindingException\_x000D\_\_x000A\_\<S S="Error"\> + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SetContentCommand\_x000D\_\_x000A\_\<S S="Error"\> _x000D\_\_x000A_", “stdout”: “”, “stdout\_lines”: }

What could be the exact reason? Or is there any other of creating a service on a windows machine?

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [April 9, 2016, 7:46pm UTC](https://forum.ansible.com/t/how-to-create-a-service-on-a-windows-10-machine/21109/2 "2016-04-09T19:46:25Z")

</div>

sc is a powershell alias for ‘set-content’

If you change your raw command to

raw: sc.exe …

it will probably work.

Better still install nssm (which is a service manager) and use win\_nssm module.

There is also a win\_service\_configure module if you prefer for creating modules but it hasn’t been merged into ansible yet. Its here - [https://github.com/ansible/ansible-modules-extras/pull/1115](https://github.com/ansible/ansible-modules-extras/pull/1115)  
perhaps you could test it?

Hope this helps,

Jon
