'How to run windows batch file within shell script?

I am not sure how to run aps.bat command within a shell script on Windows 10.

I have tried a couple of different approaches, without success I do not have more details.

Please have a look at the code below:

#!/bin/bash

output = aps.bat build $PWD;

# do some work...

echo "$output";

Basically, I need aps.bat command to be executed and to store the output to the variable.



Solution 1:[1]

#!/bin/bash

cd /e
output=$(cmd.exe /C  "aps.bat build $PWD")

# do some work...

echo $output

Solution 2:[2]

Below piece of script should work, given that the bat script should be in the same path as shell script

#!/bin/bash

output = $cmd ./aps.bat build $PWD;

#do some work...

echo "$output";

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Asish