# Interact with a python script running on a remote windows machine

**URL:** <https://forum.ansible.com/t/interact-with-a-python-script-running-on-a-remote-windows-machine/10907>\
**Category:** Guides, FAQs & Howtos\
**Tags:** windows, playbook, howto\
**Created:** [November 14, 2024, 9:50am UTC](https://forum.ansible.com/t/interact-with-a-python-script-running-on-a-remote-windows-machine/10907 "2024-11-14T09:50:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![panos](https://avatars.discourse-cdn.com/v4/letter/p/b782af/32.png) [@panos](https://forum.ansible.com/u/panos)\
**Post date:** [November 14, 2024, 9:50am UTC](https://forum.ansible.com/t/interact-with-a-python-script-running-on-a-remote-windows-machine/10907/1 "2024-11-14T09:50:16Z")

</div>

Hello,  
Is there any way to have a python script, located on a remote windows host, and run it from Ansible interacting (giving input) with it?

---

<div class="post-metadata">

**Author:** ![mikemorency](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mikemorency/32/2672_2.png) [@mikemorency](https://forum.ansible.com/u/mikemorency)\
**Post date:** [November 14, 2024, 2:11pm UTC](https://forum.ansible.com/t/interact-with-a-python-script-running-on-a-remote-windows-machine/10907/2 "2024-11-14T14:11:22Z")

</div>

It depends on what you mean by “interacting”.

To just run the script while passing input args, you can use win\_shell

```auto
- name: Run a python script
  ansible.windows.win_shell: python c:\foo\script.py arg1 arg2 arg3

```

See the docs for more examples, there are keywords to help pass in arguments, stdin, change the working dir, etc [ansible.windows.win\_shell module – Execute shell commands on target hosts — Ansible Community Documentation](https://docs.ansible.com/ansible/latest/collections/ansible/windows/win_shell_module.html)

Passing in args in response to prompts is more difficult. I dont think theres an ansible native way to do it (there is the `expect` module but that is not for windows). You could try to write a powershell script that uses `wexpect` to execute your python script, and then have ansible call the powershell script
