Saturday, June 18, 2011

Getting password in batch file

This batch script gets the password without displaying user input. Tested only in XP. Vbs script is required.
@echo off
echo wscript.echo CreateObject("ScriptPW.Password").GetPassword()>%temp%\getpwd.vbs
set pwd=Password: <nul
for /f "delims=" %%i in ('cscript /nologo %temp%\GetPwd.vbs') do set pwd=%%i
echo "%pwd%"
The last line shows the user password for testing purposes. Note that password must be enclosed in double quotes to prevent bad inputs that contains &.

No comments:

Post a Comment