What does /p mean in set /p?

blaizor picture blaizor · Jan 5, 2015 · Viewed 125k times · Source

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

<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 points for anyone who knows what all the switches for ping stand for, such as -n, -w, -a, -s, and what the switch /L in for is meant to stand for. (L = number?)

Even More Bonus Points for anyone who can name any other seemingly stupid 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.

Answer

user1595923 picture user1595923 · Oct 20, 2016

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.