DOS - Input

Card Puncher Data Processing

About

How to ask input data at the console.

Type

Clear

The set command with the /P switch allows to set the value of a variable to a line of input entered by the user.

SET /P variable=[promptString]

where:

  • promptString (Optional) displays the specified promptString before reading the line of input.

Masked (Password)

@echo off
set "psCommand=powershell -Command "$pword = read-host 'Enter Password' -AsSecureString ; ^
    $BSTR=[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pword); ^
        [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)""
for /f "usebackq delims=" %%p in (`%psCommand%`) do set password=%%p
echo %password%

See ref







Share this page:
Follow us:
Task Runner