中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-07 12:50
48,040 topics / 350,125 posts / today 0 new / 48,252 members
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.
Printable Version  1,636 / 6
Floor1 yovie Posted 2008-01-24 10:18
初级用户 Posts 42 Credits 92 From 重庆市巫山县
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 ]
Floor2 yovie Posted 2008-01-26 14:00
初级用户 Posts 42 Credits 92 From 重庆市巫山县
Hehe. Fixed it and reposted.
Floor3 plp626 Posted 2008-01-26 14:45
银牌会员 Posts 1,020 Credits 2,278
Floor4 suntb Posted 2008-01-26 15:40
高级用户 Posts 277 Credits 581
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"
Floor5 HAT Posted 2008-01-27 01:20
版主 Posts 5,017 Credits 9,023
// 无奈何 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.
Floor6 yovie Posted 2008-01-28 12:13
初级用户 Posts 42 Credits 92 From 重庆市巫山县
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.
Floor7 Shinaterry Posted 2008-03-28 15:41
初级用户 Posts 51 Credits 97
-_-!!! Why can't I run it?
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023