I think I obtained this useful piece of .bat code from a Computer Hope forum. I use it regularly on Windows XP.
:GetPassword
pushd %tmp%
>p.vbs echo WSH.Echo CreateObject("ScriptPW.Password").GetPassword
for /F usebackq %%a in (`cscript //Nologo p.vbs`) do set %1=%%a
del p.vbs
popd
However, it fails when ported to Windows 7 with the following error message:
C:\Users\John\AppData\Local\Temp\p.vbs(1, 1) Microsoft VBScript runtime error: A
ctiveX component can't create object: 'ScriptPW.Password'
Thanks in advance for any help you may be able to provide.