D
D
ddSanitt2019-05-09 19:16:05
cmd/bat
ddSanitt, 2019-05-09 19:16:05

What is the role of parameters in batfiles?

There is such a batch file:

@echo off 
u: 
set /p var1="‚ўҐ¤ЁвҐ ЇҐаўл© Ї а ¬Ґва: " 
set /p var2="‚ўҐ¤ЁвҐ ўв®а®© Ї а ¬Ґва: " 
if not defined var1 (goto error) 
if not defined var2 (goto error) 
if "%var1%" == "%var2%" (goto eq) else (goto uneq) 
:eq 
echo %var1% > var1.txt 
echo 2222 >> var1.txt 
eq.bat 
exit 
:uneq 
md var1 
echo %var2% > var1\var2.txt 
echo 1111 >> var1\var2.txt 
uneq.bat 
exit 
:error 
echo Ћ¤Ё Ё«Ё ®Ў Ї а ¬Ґва Ґ § ¤ л 
pause 
exit

There, environment variables are used, but I need to do it through the parameters. Well, that is %1-%9. I can not understand the role of these parameters, and what they are

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Moskus, 2019-05-09
@Moskus

You're not good at searching...
https://ss64.com/nt/syntax-args.html
https://ss64.com/nt/set.html

R
res2001, 2019-05-10
@res2001

There are no environment variables in the script, but parameter input from the keyboard: set /p ...
Instead of these commands, use

set "var1=%~1"
set "var2=%~2"

%~1and are the first and second command line options. %~2

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question