windows /p 在 set /p 中是什么意思?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27773805/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 18:52:56  来源:igfitidea点击:

What does /p mean in set /p?

windowsbatch-fileabbreviation

提问by blaizor

What does /pstand for in set /p=? I know that /enables a switch, and I'm fairly sure that I know /ais for arithmetic. I've heard numerous rumours, some saying /pis for prompt, others stating it stands for print. The only reason I slightly doubt it is promptis because in many cases it does not ask for a prompt, yet prints on the screen, such as

什么是/p代表的set /p=?我知道这会/启用一个开关,而且我相当确定我知道/a是为了arithmetic. 我听过无数的谣言,有的说/p是为了prompt,有的说它代表着print。我稍微怀疑它的唯一原因prompt是因为在许多情况下它不要求提示,而是打印在屏幕上,例如

<nul set /p=This will not generate a new line

But what I want to know is: Do we really know what it stands for?

但我想知道的是:我们真的知道它代表什么吗?

Bonus pointsfor anyone who knows what all the switches for pingstand for, such as -n, -w, -a, -s, and what the switch /Lin foris meant to stand for. (L = number?)

奖励积分的人谁知道所有的交换机ping立场,比如-n-w-a-s,,什么开关/Lfor旨在代表。(L =数字?)

Even More Bonus Pointsfor anyone who can name any other seeminglystupid switches in batch file

任何可以在批处理文件中命名任何其他看似愚蠢的开关的人都可以获得更多奖励积分

Please understand that I already know what all these switches and prefixes and whatnot mean, I am not asking for their meaning nor purpose. Thanks in advance.

请理解,我已经知道所有这些开关和前缀的含义以及其他含义,我不是在询问它们的含义或目的。提前致谢。

采纳答案by SomethingDark

For future reference, you can get help for any command by using the /?switch, which should explain what switches do what.

为了将来参考,您可以通过使用/?开关获得任何命令的帮助,它应该解释哪些开关做什么。

According to the set /?screen, the format for set /pis SET /P variable=[promptString]which would indicate that the p in /pis "prompt." It just prints in your example because <nulpasses in a nul character which immediately ends the prompt so it just actslike it's printing. It's still technically prompting for input, it's just immediately receiving it.

根据set /?屏幕,set /pis的格式SET /P variable=[promptString]将指示 p 输入/p是“提示”。它只是打印在你的榜样,因为<nul传球的空字符其立即结束提示,以便它只是充当喜欢它的打印。它仍然在技术上提示输入,它只是立即接收它。

/Lin for /Lgenerates a List of numbers.

/Linfor /L生成一个L 列表

From ping /?:

来自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.

回答by user1595923

The /Pswitch 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.

/P开关允许您将变量的值设置为用户输入的一行输入。在读取输入行之前显示指定的 promptString。promptString 可以为空。

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 /Pis included. Both tested on Windows 8.1 Pro, but it's the same on 7 and 10.

将变量设置为 txt 文件的内容(第一行)。除非/P包含 ,否则此方法将不起作用。两者都在 Windows 8.1 Pro 上进行了测试,但在 7 和 10 上是相同的。