China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-07 12:00
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Here is a batch script example to achieve displaying `*` when inputting characters: ```batch @echo off setlocal enabledelayedexpansion set "password=" echo Please enter your password: :input set "key=" for /f "delims=" %%a in ('choice /c 0123456789abcdefghijklmnopqrstuvwxyz /t 0 /d 0 /n set /p "key=" if "!key!"=="" goto input set "password=!password!!key!" echo * goto input ``` Please note that this is a simple example, and there are more advanced ways to handle password input and security, but this basic script can display `*` while inputting characters. View 1,634 Replies 6
Original Poster Posted 2008-01-24 10:18 ·  中国 江苏 无锡 电信
初级用户
Credits 92
Posts 42
Joined 2007-08-14 09:14
18-year member
UID 95100
Gender Male
From 重庆市巫山县
Status Offline
Referenced the original大人 Herbert Kleebauer's ASCODE part



  1. @echo off&cls
  2. chcp 437>nul&graftabl 936>nul
  3. for /f "delims=: tokens=1" %%i in ('findstr /i /n "^:writepass$" "%~f0"') do set line=%%i
  4. <"%~f0" more +%line%|debug>nul
  5. set "ps="
  6. set n=0
  7. set /p=请输入密码:<nul
  8. :start
  9. if %n%==256 (
  10. echo  &&goto e
  11. ) else (
  12. for /f "delims=" %%i in ('password.com') do (
  13. if "%%i"=="?" goto e
  14. set "q=%%i"
  15. if "%%i" equ "?" (call :p "%%i") else (
  16. if "%%i" lss "? " (GOTO :start)
  17. set /p=*<nul
  18. set /a n+=1
  19. if "%%i" geq "? " call set "ps=%%ps%%%%q:~1%%"
  20. )))
  21. goto start

  22. :p
  23. if not "%ps%" equ "" (
  24. set "ps=%ps:~0,-1%"
  25. SET /p=  <nul
  26. )
  27. GOTO :eof

  28. :e
  29. :::Here you can do what you wanna do:::
  30. echo.
  31. echo 密码为:"%ps%"
  32. del password.com
  33. pause>nul
  34. goto :eof
  35. ::下面的请不要随意修改::
  36. :writepass
  37. A
  38. MOV DX,111
  39. MOV AH,09
  40. INT 21
  41. MOV AH,01
  42. INT 21
  43. MOV AH,4C
  44. INT 21
  45. INT 20
  46. DB '?'24 0D 0A 1A

  47. R CX
  48. 108
  49. N password.com
  50. W
  51. Q

Yovie posted on: 2008-01-26 12:51


[ Last edited by yovie on 2008-1-28 at 12:11 PM ]
拾人牙慧者!
Floor 2 Posted 2008-01-26 14:00 ·  中国 江苏 无锡 电信
初级用户
Credits 92
Posts 42
Joined 2007-08-14 09:14
18-year member
UID 95100
Gender Male
From 重庆市巫山县
Status Offline
Hehe. Fixed it and reposted.
拾人牙慧者!
Floor 3 Posted 2008-01-26 14:45 ·  中国 陕西 西安 电信
银牌会员
★★★★
钻石会员
Credits 2,278
Posts 1,020
Joined 2007-11-19 13:34
18-year member
UID 103127
Gender Male
Status Offline
Floor 4 Posted 2008-01-26 15:40 ·  中国 福建 福州 联通
高级用户
★★
Credits 581
Posts 277
Joined 2006-12-23 05:10
19-year member
UID 74328
Gender Male
Status Offline
When saving the building owner's code as a CMD and running it, it prompts: "password.com is not a valid Win32 application. Access denied"
Floor 5 Posted 2008-01-27 01:20 ·  中国 重庆 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
// 无奈何 posted on: 2008-01-26 12:51

Is the original poster the alternate account of user 无奈何^_^
You should at least read the usage instructions when using someone else's batch script, heh heh.
Floor 6 Posted 2008-01-28 12:13 ·  中国 江苏 无锡 电信
初级用户
Credits 92
Posts 42
Joined 2007-08-14 09:14
18-year member
UID 95100
Gender Male
From 重庆市巫山县
Status Offline
Hehe. I'm sorry, upstairs. I forgot to change that signature. [Hey, being a moderator is way out of my reach!]
Also, try saving it as *.bat in floor 4.
拾人牙慧者!
Floor 7 Posted 2008-03-28 15:41 ·  中国 广东 珠海 电信
初级用户
★★
Credits 97
Posts 51
Joined 2008-03-19 15:26
18-year member
UID 113404
Gender Male
Status Offline
-_-!!! Why can't I run it?
Forum Jump: