50

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?

VLAZ
  • 26,331
  • 9
  • 49
  • 67
blaizor
  • 989
  • 2
  • 9
  • 20
  • Type Help in the command prompt. For each command listed type `help ` (eg `help dir`) or ` /?` (eg `dir /?`). Using Redirection is merely automating a command, any command that reads from StdIn. See http://stackoverflow.com/questions/31820569/trouble-with-renaming-folders-and-sub-folders-using-batch for punctuation. –  Oct 20 '16 at 19:55

2 Answers2

59

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.

Stephan
  • 53,940
  • 10
  • 58
  • 91
user1595923
  • 641
  • 6
  • 7
  • 5
    Thanks for this additional answer. It was easier for me to understand. I just came here from google looking for a simple explanation, and I know sometimes if there's already an accepted answer, people won't post another. – gamingexpert13 Jul 09 '19 at 19:19
  • 3
    This should be the marked answer. Other people responding, like pulling teeth for a simple answer. It shouldn't be like that. – Tastybrownies Aug 29 '19 at 17:17
  • To clarify, does `/P` set the value of a CMD variable or an Environment Variable? – edddd Apr 23 '22 at 06:51
35

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 /p is SET /P variable=[promptString] which would indicate that the p in /p is "prompt." It just prints in your example because <nul passes in a nul character which immediately ends the prompt so it just acts like it's printing. It's still technically prompting for input, it's just immediately receiving it.


NOTE: The answers below this point are for a previous version of the question.

/L in for /L generates a List of numbers.

From 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.
SomethingDark
  • 13,229
  • 5
  • 50
  • 55
  • 1
    I already knew what they did, and I already knew of the [command] /? syntax, but I never thought to use it because, as stated, I already knew what they did. But now that a see it, the way it is explained in the /? menus is a lot more down-to-earth as to why the abbreviation is what it is - I always used things like ss64.com and the like. Accepted, good answer. – blaizor Jan 05 '15 at 05:45