/p
代表set /p=
代表什么?我知道/
启用了切换功能,我确信/a
代表arithmetic
。我听过很多谣言,有些人说/p
是prompt
,有些人说它代表print
。我稍微怀疑它的唯一原因是prompt
是因为在很多情况下它不会要求提示,而是在屏幕上打印,例如
<nul set /p=This will not generate a new line
但我想知道的是:我们真的知道它代表什么吗?
知道ping
的所有切换代表什么的人的 加分,例如-n
,-w
,-a
,{ {1}}以及-s
中的切换/L
意味着代表什么。 (L = 数字?)
更多奖励积分
请理解我已经知道所有这些开关和前缀以及意味着什么,我不是要求它们的含义或目的。提前谢谢。
答案 0 :(得分:21)
The /P
switch allows you to set the value of a variable to a line of input entered by the user. Displays the specified promptString before reading the line of input. The promptString can be empty.
Two ways I've used it... first:
SET /P variable=
When batch file reaches this point (when left blank) it will halt and wait for user input. Input then becomes variable.
And second:
SET /P variable=<%temp%\filename.txt
Will set variable to contents (the first line) of the txt file. This method won't work unless the /P
is included. Both tested on Windows 8.1 Pro, but it's the same on 7 and 10.
答案 1 :(得分:12)
为了将来参考,您可以使用/?
开关获取任何命令的帮助,这应该解释哪些开关可以做什么。
根据set /?
屏幕,set /p
的格式为SET /P variable=[promptString]
,表示/p
中的p为“提示”。它只是在你的例子中打印,因为<nul
传递了一个nul字符,它立即结束提示,所以它只是行为就像打印一样。它仍然在技术上提示输入,它只是立即接收它。
/L
中的{p> for /L
生成 L 数字。
来自ping /?
:
Usage: ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS]
[-r count] [-s count] [[-j host-list] | [-k host-list]]
[-w timeout] [-R] [-S srcaddr] [-4] [-6] target_name
Options:
-t Ping the specified host until stopped.
To see statistics and continue - type Control-Break;
To stop - type Control-C.
-a Resolve addresses to hostnames.
-n count Number of echo requests to send.
-l size Send buffer size.
-f Set Don't Fragment flag in packet (IPv4-only).
-i TTL Time To Live.
-v TOS Type Of Service (IPv4-only. This setting has been deprecated
and has no effect on the type of service field in the IP Header).
-r count Record route for count hops (IPv4-only).
-s count Timestamp for count hops (IPv4-only).
-j host-list Loose source route along host-list (IPv4-only).
-k host-list Strict source route along host-list (IPv4-only).
-w timeout Timeout in milliseconds to wait for each reply.
-R Use routing header to test reverse route also (IPv6-only).
-S srcaddr Source address to use.
-4 Force using IPv4.
-6 Force using IPv6.