While you can use win_shell I find it is better to use win_command when it comes to running executables, this way you don't fall prey to the shell specific escaping, e.g. when using win_shell you usually have to do it like;
- win_shell: &"C:\Program Files\someapp\app.exe"
compared to
- win_command: '"C:\Program Files\someapp\app.exe"'
For your specific situation I would try (note you would need some sort of when clause to skip this task if it is already uninstalled);
- name: uninstall application
win_command: '"C:\Program Files (x86)\My Software\It Is Mine\myagent\uninstall.exe" /S "_?=C:\Program Files (x86)\My Software\It Is Mine\myagent"'
In this example, I have
* put the entire win_command value inside single quotes that tells the Ansible yml parser this is all one value and ignore things like double quotes, backslashes and other escaping chars
* used double quotes to enclose the first argument which is the path to the executable as well as the 3rd argument which also has spaces in it
* I didn't use jinja2 blocks but if you need to substitute the path, leave the quoting as is as it is very important they stay like that, e.g. make it like
- win_command: '"{{ uninstall_path }}" /S "_?={{ unisntall_path }}"'
In the end Windows will see this as
argv[0] = C:\Program Files (x86)\My Software\It Is Mine\myagent\uninstall.exe
argv[1] = /S
argv[2] = _?=C:\Program Files (x86)\My Software\It Is Mine\myagent
Where argv[0] is the path to the executable that is used to start the process. This follows Microsoft standard rules for argument parsing and in the application entry point, the argv array above is what will be passed in so it should work. Hopefully this helps you with what you need to do.
Thanks
Jordan