# Ansible win\_shell hangs

**URL:** <https://forum.ansible.com/t/ansible-win-shell-hangs/31732>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [November 27, 2019, 9:52am UTC](https://forum.ansible.com/t/ansible-win-shell-hangs/31732 "2019-11-27T09:52:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bairava\_Surya](https://avatars.discourse-cdn.com/v4/letter/b/f1d935/32.png) [@Bairava\_Surya](https://forum.ansible.com/u/Bairava_Surya)\
**Post date:** [November 27, 2019, 9:52am UTC](https://forum.ansible.com/t/ansible-win-shell-hangs/31732/1 "2019-11-27T09:52:37Z")

</div>

hi all,

when am trying to execute below ansible command or .bat file it juts hangs at below line can anyone help me on this .

play 1:

- name: check rdp on windows  
win\_shell: ‘mstsc /v:’  
args:  
executable: cmd  
register: result
- debug:  
var: result

Play 2:

- name: execute bat file  
win\_command: C:\devops\demo.bat

when i execute any above play it just hangs at below output

Output:  
TASK [check rdp on windows] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* task path: /home/vagrant/ansible/server\_control.yml:13 Using module file /usr/lib/python2.7/site-packages/ansible/modules/windows/win\_shell.ps1 ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5986 TO checking if winrm\_host is an IPv6 address WINRM CONNECT: transport=ssl endpoint=https://:5986/wsman WINRM OPEN SHELL: F40E1253-9543-4A6D-A791-D747BDC7B7D6 EXEC (via pipeline wrapper) **WINRM EXEC ‘PowerShell’ [‘-NoProfile’, ‘-NonInteractive’, ‘-ExecutionPolicy’, ‘Unrestricted’, ‘-’] (It just hang here)**

---

<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:** [December 1, 2019, 8:52pm UTC](https://forum.ansible.com/t/ansible-win-shell-hangs/31732/2 "2019-12-01T20:52:54Z")

</div>

Running a command through Ansible is not designed to run interactive programs. Everything is run in the background with no interactive Window and will wait until the process has exited. Because running mstsc is a GUI application, it will stay open forever which results in win\_shell/win\_command waiting forever for it to quit which will never occur as no one can see the Window. There are ways to run things in the background asynchronously but in this case there is no reason as opening a GUI application from Ansible will not display it on any interactive desktop.

---

<div class="post-metadata">

**Author:** ![Bairava\_Surya](https://avatars.discourse-cdn.com/v4/letter/b/f1d935/32.png) [@Bairava\_Surya](https://forum.ansible.com/u/Bairava_Surya)\
**Post date:** [December 2, 2019, 3:20am UTC](https://forum.ansible.com/t/ansible-win-shell-hangs/31732/3 "2019-12-02T03:20:56Z")

</div>

hi jordan,

thanks for your reply can you please tell us how this can be achieved through other programming or automation.
