Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to read only 1 char (number, if be be exactly) from cmd.exe. It must be done in only one keystroke. Is that possible? Not only cmd.exe, but I mean all standard utilities in windows (supported by WinXP-Win7).

PS set /p val=request is not what I looking for. It reads string, not only 1 char and require [enter] key. I need something what works like OnKeyDown: read 1 char and continue script execution, no [enter] needed.

share|improve this question
I'm not positive how to answer this. Perhaps some more explaination on why you need this will help? – EBGreen Jun 28 '11 at 17:55
Are you reading from the keyboard or from another program's output? – grawity Jun 28 '11 at 20:39
up vote 1 down vote accepted

Not only cmd.exe, but I mean all standard utilities in windows (supported by WinXP-Win7).

Why would it need to be possible for, say, edlin.exe? That's a nonsensical requirement.

If you want to prompt for a single character, returning immediately once one is entered, then you are going to have to use some form of extra utility over and above what comes in the box with Windows NT 5.1, even if it's simply a Win32 clone of the MS-DOS 6.2 program (which, being an MS-DOS program, won't work on x86-64 Windows, of course).

With JP Software's TCC/LE, which is a replacement command interpreter, the built-in INKEY command does exactly what you ask for and can be used thusly:

inkey %%key

The key pressed is then in the key environment variable.

Alternatively, in the Windows NT 4.0 Server Resource Kit and later, Microsoft provides choice.exe, which is a Win32 clone of the MS-DOS Note, however, that this is the Server Resource Kit. With Windows NT Server 5.2 and later, choice.exe is bundled in with Windows itself. However, again, note that this is the Server edition of Windows.

share|improve this answer
I found choice.exe in my Win7x64: C:\Windows\winsxs\x86_microsoft-windows-choice_31bf3856ad364e35_6.1.7600.16385_n‌​one_c33d412fed16819c It works great. – SmartiesForTheWin Jun 30 '11 at 17:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.