# Windows service status not changing from stoppending to stopped

**URL:** <https://forum.ansible.com/t/windows-service-status-not-changing-from-stoppending-to-stopped/25192>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [August 7, 2017, 11:30am UTC](https://forum.ansible.com/t/windows-service-status-not-changing-from-stoppending-to-stopped/25192 "2017-08-07T11:30:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![amitbitcse](https://avatars.discourse-cdn.com/v4/letter/a/b77776/32.png) [@amitbitcse](https://forum.ansible.com/u/amitbitcse)\
**Post date:** [August 7, 2017, 11:30am UTC](https://forum.ansible.com/t/windows-service-status-not-changing-from-stoppending-to-stopped/25192/1 "2017-08-07T11:30:45Z")

</div>

While executing my playbook, I cancelled the playbook execution when win\_service task for stopping a service was in play. When I re-ran the playbook, it failed to stop the windows service. The windows service status was changed from “running” to “stoppending” after the first playbook execution. The status of the service is displayed as “Stopping” on the windows machine.

The code snippet from my playbook is as below:-

`

- hosts: all  
gather\_facts: no  
tasks:

- name: Service ‘XYZ’ exists?  
win\_service:  
name: XYZ  
register: XYZ\_service

- name: Stop ‘XYZ’ service  
win\_service:  
name: XYZ  
state: stopped  
when: XYZ\_service.exists  
`

Is this an expected behavior?

Please provide a solution this problem.
