Running exe on windows from a batch file

Where is the setup-x86_64.exe located? By default commands run from win_command and win_shell are run in the user’s home directory which means it will be trying to execute C:\Users\pkmbuilder\setup-x86_64.exe. If the exe is located in another directory you will either have to reference the full/relative path from that user’s home directory or change the working directory on the task. To change the working directory to another path (the example is C:\temp) you can set the task as;

`

  • win_command: cmd.exe /c dir
    args:
    chdir: C:\temp
    `

Thanks

Jordan

Personally, I would bypass the batch file and just call the executable directly like

  • name: install Cygwin
    win_command: C:\Users\pkmbuilder\setup-x86_64.exe --root C:\cygwin64 --quiet-mode --site http://cygwin.mirror.constant.com --packages “openssh,rsync,zip,vim,wget”

Note if you are using an Ansible version before 2.4, change “openssh,rsync,zip,vim,wget” to "openssh,rsync,zip,vim,wget". If you are on 2.4 keep it as it is

This way you aren’t reliant on a file being present on the server and are bypassing cmd which could obfuscate some results. You can also use win_package but you would need to determine the product id before hand but doing so would give you some idempotency.

Thanks

Jordan

Hey,

Not sure if either of these are the answer but a couple of things you can try..

Try using win_shell instead of win_command. I think it may handle args differently (because it is running inside a shell).

Another thing you could try is using with_items to pass each of the packages you are installing separately, thereby avoiding the comma in your command line. Probably a bit slower but if it works it might be good enough for you to move on to the next thing.

Hope this helps,

Jon