# Ansible Win\_command

**URL:** <https://forum.ansible.com/t/ansible-win-command/30663>\
**Category:** Ansible Project\
**Created:** [June 27, 2019, 4:32am UTC](https://forum.ansible.com/t/ansible-win-command/30663 "2019-06-27T04:32:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sindhu\_shree](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@sindhu\_shree](https://forum.ansible.com/u/sindhu_shree)\
**Post date:** [June 27, 2019, 4:32am UTC](https://forum.ansible.com/t/ansible-win-command/30663/1 "2019-06-27T04:32:02Z")

</div>

Hi All,  
I need help in executing batch file which has some prompts.  
Am using following lines of script

- name: run an executable with custom working dir  
win\_command: pisrvstop.bat /argument1 “/argument 2 with space”  
args:  
chdir: F:\Program Files\PI\adm  
async: 120  
poll: 5

it works fine but it will not answer for the prompts. How do i set the answers for prompt?

---

<div class="post-metadata">

**Author:** ![Angel\_Rengifo\_Cancin](https://avatars.discourse-cdn.com/v4/letter/a/9e8a1a/32.png) [@Angel\_Rengifo\_Cancin](https://forum.ansible.com/u/Angel_Rengifo_Cancin)\
**Post date:** [June 27, 2019, 6:47pm UTC](https://forum.ansible.com/t/ansible-win-command/30663/2 "2019-06-27T18:47:44Z")

</div>

May the expect module be useful for you?

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [June 27, 2019, 8:18pm UTC](https://forum.ansible.com/t/ansible-win-command/30663/3 "2019-06-27T20:18:36Z")

</div>

Ansible modules are designed to be run in a non-interactive fashion, you won’t receive the prompt on the controller as that’s just not how Ansible works. You also won’t be able to use expect for Windows as that is a Python module. Your best bet is to the use stdin option for win\_command to send data over the stdin pipe. This is a very basic mechanism but if all you need to do is type ‘y’ then send y over stdin.

Thanks

Jordan

---

<div class="post-metadata">

**Author:** ![sindhu\_shree](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@sindhu\_shree](https://forum.ansible.com/u/sindhu_shree)\
**Post date:** [July 5, 2019, 5:24am UTC](https://forum.ansible.com/t/ansible-win-command/30663/4 "2019-07-05T05:24:28Z")

</div>

Jordan,

Thanks for the detailed description. Actually am working on stopping services which has dependencies just like service A dependent on Service B, am having issue in this scenario. Can you please give some info on stopping dependencies as well?

---

<div class="post-metadata">

**Author:** ![sindhu\_shree](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@sindhu\_shree](https://forum.ansible.com/u/sindhu_shree)\
**Post date:** [July 5, 2019, 5:26am UTC](https://forum.ansible.com/t/ansible-win-command/30663/5 "2019-07-05T05:26:12Z")

</div>

Thanks for the info. I look into it.
