I have tried with "win_scheduled_task"option like below…This time its not giving any error …and its not stopping the services as well. And the windows server i am trying is on 2008R2.
Please tell how exactly i have to use this module to run the python script.
path needs to be a location for storing the task definition within scheduled tasks. If you run the scheduled tasks program on windows you can browse through the tree structure to find an appropriate location - its not a file system path
Also you probably need to set executable: to the full path to wherever python is installed on your windows machine and use arguments to tell python where the script is i.e. D:\smtn17\scripts\pystop.py
You might also need to set the user that scheduled tasks runs your python script as.
If you wanted to go the scheduled task route I would use https://docs.ansible.com/ansible/latest/modules/win_scheduled_task_module.html#examples instead of the 2.4 link. win_scheduled_task went through a big overhaul in 2.5 deprecating some of the options like path. Anyway there’s a reason why I had that as the last option, you are going to have much more luck doing it with become like this
`
name: run script with become
win_command: python.exe D:\smtn17\scripts\pystop.py
become: yes
become_method: yes
vars: # the values can be anything, I’m just using the standard connection user/var but you can choose any other
ansible_become_user: ‘{{ ansible_user }}’
ansible_become_pass: ‘{{ ansible_password }}’