How to execute .bat file with batch parameters - ruby

I am trying to execute a .bat file with Ruby using:
System("path\to\.bat")
However, I would like to pass parameters to this file. Is this possible?

Just pass them as you would do it normally.
`path\to\.bat -some=flag another-way`

Related

running batch files inside another batch file

I have made a batch script to run some .exe files and .bat files. The format of the script is as follows:
a.exe
b.exe
c.bat
d.bat
e.bat
f.exe
g.exe
but the problem is when I run the script it is only executed till c.bat. d.bat is not executing. Is there any problem in writing the batch script for executing other batch files?
just in case you missed the full application of call
a.exe
b.exe
call c.bat
call d.bat
call e.bat
f.exe
g.exe
is how your script should now look.
if you use the 'call' command, the batch files next batch/exe file wouldn't execute unless the batch file stops. Instead, use the 'start' command. that way, it'll execute the batch in a new window

Is it possible to run a batch file as part of the Run command (i.e. F5)?

I'd like to execute a batch file when I run the solution which will prepare the environment that I'm deploying to. I want this to run first thing when I hit F5 before anything else happens. Is this possible? If so, how?
In the project's property pages, under Debugging tab, set the proper value for Command option. Default value is $(TargetPath), which will run the output executable. Just specify your batch file there.
You will have to run the executable on your own in this case. I suggest passing $(TargetPath) as a parameter to your batch script and then executing the parameter.

Using redirects inside a batch file

This seems like I'm missing something obvious but I can't get redirects (>) to work in a .bat / .cmd file.
From the command line, this works as expected and sends the output and error streams to the log file:
doxygen doxygen.config 2>&1 > doxygen.log
Putting the exact same line inside a batch file and running it doesn't work however. It looks like it tries to write the entire command to the log file rather than execute it and then loops??
How do I get output redirects to work inside a bat / cmd file? In case it makes a difference, I am using Win7 and have tried from cmd and powershell.
Perhaps the batch script is calling itself. I would suggest you explicitly specify the extension for the executable your script is calling:
doxygen.exe doxygen.config 2>&1 > doxygen.log

How do I run MinGW with a script?

Is there a way to run MinGW, from msys.bat or any other method, from a batch file and input a .sh file for it to run?
Batch file like this
C:\MinGW\msys\1.0\bin\sh ~/test.sh
pause

Windows .bat file doesn't execute its sequence

I created a simple install.bat file into my application folder, to execute its thing on windows.
But it only executes the first line of the .bat file.
Is there something that I need to add so it continues after the first one is done?
copy something somewhere
move something somewhereelse
gem install etc
Above are the type of commands that are in the .bat.
Do I need to anything something inbetween?
Is the first command in your batch file actually a copy command, or is it a command that's running another batch file?
Running a batch file from another by simply using the second batch file;s name will not return to the calling batch file.
If you want one batch file to invoke another and return you have to use the call command.
Are you overwriting a file? If so you'll need to add the /Y to the copy command to supress the prompt that asks if you want to overwrite the file.
Use the /h parameter to get help on the copy command. It will show this usage and some others.
As written above, all three lines will execute. I imagine that the second and third lines are failing. You should capture the output which will explain why those lines failed.

Resources