One of the first lines in a batch file I have is this:
IF '%FirstServer2%' == 'No' goto :SkipSolution
The variable %FirstServer2% is not declared anywhere, so it must be passed to the batch file somehow. So, how can I pass in the value?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Simply set the environment variable beforehand and start your batch afterwards.
Named parameters are a bit misleading in this case, as
FirstServer2is just a normal environment variable.I have used a similar technique in a batch I wrote once which was pretty configurable. Depending on whether variables were set or not it assumed some default values or went with already defined ones. This is a pretty useful technique if you want to avoid excessive parsing of parameters passed directly to the batch.