You may put and use command-line parameters into your batch-files. Suppose you had a batchfile called "test.bat" and these were the contents:
and at the command line you entered: test.bat Hi, the output would be "Hi". If you entered test.bat bye you would get no response because the parameter did not match. the "%1" refers to the first parameter on the command line after the batch file name. If you want to two parameters, the would look like this:
You could also just spit out what someone types in without a condition:
Then typing test.bat dont tell me what to do would produce dont tell me what to do because it is set up to handle 6 parameters and there are six words. You can tease someone by changing the order:
do me dont tell to whatMaking your own variablesYou may use the SET command to create your own internal paramaters. This batch file:
Will print Hi Joe is myvar. Notice a few important points. when we initialize myvar there are no % around it. When we use it, it must be between two %. Also, there must be no spaces between the = and the terms. When myvar is not in a set command or between % it is treated as a literal string.You can make up your own parameter names and have many of them: