问题都很菜,希望大家有点耐心。。。呵。。
问题一:
set a=
set/p a=请输入关键字……
start
http://www.baidu.com/s?wd=%a%
自带的帮助是这样写的:SET /P variable=
那第一句等号右边怎么什么都没有?那到底把什么指派给变量a了?
还有这么一句:”set命令不容许变量含有等号“怎么理解?
问题二:
看到这样一个帖子:
set "STARTPRGNAME=%STARTPRGNAME:"=%"
语句中:"=%"表示什么意思?
if /i "%STARTPRGNAME%" == "cmd" goto :cmd_exe
语句中/i表示什么意思?
if not "%STARTPRGNAME:.bat=%" == "%STARTPRGNAME%" goto :cmd_or_bat
语句中:.bat表示什么意思?
第一句中:set后面的语句为何用引号括起来?代表什么?还有,等号右边的
%STARTPRGNAME的意思是把什么指派给等号左边的STARTPRGNAME了?
第二句中:"%STARTPRGNAME%"是怎么回事?它和%%1有什么区别?
Problem 1:
The first line `set a=` means initializing the variable `a` without giving it an initial value. Then `set/p a=请输入关键字……` is used to let the user input a value and assign it to variable `a`. The statement "The set command does not allow variables to contain equal signs" means that if you try to assign a value to a variable using the set command, the value should not contain the equal sign character.
Problem 2:
In `set "STARTPRGNAME=%STARTPRGNAME:"=%"`, `"=%"` is used to remove all double quotes from the variable `STARTPRGNAME`. The `/i` in `if /i "%STARTPRGNAME%" == "cmd" goto :cmd_exe` means case - insensitive comparison. The `:.bat` in `if not "%STARTPRGNAME:.bat=%" == "%STARTPRGNAME%" goto :cmd_or_bat` is used to remove the substring `.bat` from the variable `STARTPRGNAME`. The reason for enclosing `set "STARTPRGNAME=%STARTPRGNAME:"=%"` in quotes is to handle cases where the variable value might contain spaces. `%STARTPRGNAME%` is getting the value of the variable `STARTPRGNAME`, and `%1` is the first command - line argument, they are different in terms of their source (one is a variable, the other is a command - line argument).
Translated:
Problem 1:
The questions are all very basic, hope everyone has a little patience... Hehe.
Problem one:
set a=
set/p a=Please enter the keyword...
start
http://www.baidu.com/s?wd=%a%
The built - in help is written like this: SET /P variable=
Why is there nothing on the right side of the equal sign in the first line? Then what is assigned to variable a exactly?
And there is such a sentence: "The set command does not allow variables to contain equal signs" How to understand it?
Problem two:
I saw such a post:
set "STARTPRGNAME=%STARTPRGNAME:"=%"
What does ":=" mean in the statement?
if /i "%STARTPRGNAME%" == "cmd" goto :cmd_exe
What does /i mean in the statement?
if not "%STARTPRGNAME:.bat=%" == "%STARTPRGNAME%" goto :cmd_or_bat
What does .bat mean in the statement?
In the first sentence: Why is the statement after set enclosed in quotes? What does it represent? Also, what does the %STARTPRGNAME on the right side of the equal sign mean? What is assigned to STARTPRGNAME on the left side of the equal sign?
In the second sentence: What is the situation of "%STARTPRGNAME%"? What is the difference between it and %1?