Execute windows batch file which called another batch file

214 views
Skip to first unread message

Gad

unread,
Jan 18, 2017, 12:20:06 PM1/18/17
to Ansible Project
Hi
Im tryin to execute "c:\my files\a.bat"
which call :  "c:\my files\c.bat"

i did try using the raw module like:

raw: "cd \"c:\my-files\" & \"c:\my-files\a.bat\""

but ansible refuse to pipe the sign &
also tried with \"&\"  but then error appears

how can i cd to a relevant directory and then execute file.bat??

win_command???

J Hawkesworth

unread,
Jan 19, 2017, 5:03:51 PM1/19/17
to Ansible Project

Can you just use the full path to the .bat file?

If you need to change the working directory, perhaps just modify the .bat file contents?

Hope this helps,

Jon

J Hawkesworth

unread,
Jan 19, 2017, 5:03:51 PM1/19/17
to Ansible Project

Gad

unread,
Jan 22, 2017, 1:11:43 AM1/22/17
to Ansible Project
i wish
activate a bat file (windows) has to be from the directory itself.
i tried to cd with "&"  and call the bat in one line
but ansible raw module does not allow to use & sign

בתאריך יום שישי, 20 בינואר 2017 בשעה 00:03:51 UTC+2, מאת J Hawkesworth:

J Hawkesworth

unread,
Jan 22, 2017, 3:30:42 AM1/22/17
to Ansible Project
Perhaps use a PowerShell script to cd and run the .bat file? You can use the script module to send and run the PowerShell script.

Hope this helps,

Jon

Reply all
Reply to author
Forward
0 new messages