I am just beginning to learn command line scripts, and I have an assignment for school in which the first part is to create a batch file that accepts two integers as parameters. The integers will be subsequently manipulated throughout the question, and I am not looking for any help with that. I have googled this many different ways, and cannot seem to come up with an answer. How do I begin this?
I know this is very basic to probably everyone that reads this, but I am asking you to cut me some slack, we all have to start somewhere.
Assuming MS-DOS, you can use %1
, %2
, etc. for input parameters.
@ECHO OFF
SET /a INT1=%1
SET /a INT2=%2
SET /a ANSWER=INT1*INT2
ECHO %ANSWER%
PAUSE
You could then call this as:
mybatchfile.bat 2 4
On windows, it is %1 %2
http://commandwindows.com/batch.htm
example:
@echo off
echo %1 %2
set /a v = %1
set /a v2 = %1 + 1
set /a v3 = %1 * 2
echo %v% %v2% %v3%
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With