批处理文件来屏蔽带*号输入没有外部文件 [英] batch file to mask input with * without an external file
本文介绍了批处理文件来屏蔽带*号输入没有外部文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要批处理文件来屏蔽输入与*没有外部文件,我需要code要快写信
例如:
关闭@echo
设置字符= *
集/ p变量=输入你的密码:
字符集=%变量%
回声%字符%
暂停
解决方案
下面是一种在一个批处理文件中使用PowerShell来做到这一点。
关闭@echo
设置psCommand = PowerShell的-Command$ PWORD =读主机输入密码-AsSecureString; ^
$ BSTR = [System.Runtime.InteropServices.Marshal] :: SecureStringToBSTR($ PWORD); ^
[System.Runtime.InteropServices.Marshal] ::的PtrToStringAuto($ BSTR)
FOR / F有usebackq delims =%%的(`%psCommand%`)p不设置密码= %% p
回声%密码%
PowerShell是默认安装在所有较新的操作系统的所以这是一个很好的妥协。如果您有支持XP的机器,你可以使用VBScript类似的事情。
i need batch file to mask the input with * without external file and i need the code to be fast to write letters
FOR EXAMPLE:
@echo off
set char=*
set /p variable=Enter your password:
set char=%variable%
echo %char%
pause
解决方案
Here is a way to do it using Powershell in a batch file
@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%
Powershell is installed by default on all newer OS's so it's a good compromise. If you have to support XP machines, you can do something similar with VBScript.
这篇关于批处理文件来屏蔽带*号输入没有外部文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文