Thursday, January 24, 2008

Masking Passwords in VBScript

I was posting an answer on ScriptingAnswers when someone asked a question on how to mask the input with the Inputbox using VBScript. I responded that you would have to either use Powershell or a HTA. I however learned that from another member that there is a way if you have XP or Server 2003. As these are the only Windows OS's that have ScriptPW.dll installed and registered.
Very Cool!
Here is how you use it! This is gathered from the Scripting Guys

   1:  Set objPassword = CreateObject("ScriptPW.Password")
   2:  WScript.StdOut.Write "Please enter your password:"
   3:  
   4:  strPassword = objPassword.GetPassword()
   5:  Wscript.Echo
   6:  Wscript.Echo "Your password is: " & strPassword

The script uses StdOut to write the message to the console and uses StdIn to capture whatever was typed. Sadly this DLL isn't available on Vista. 8( Although some people said they have been successful in registering it after copying it from an XP box. Keep in mind this does not encrypt the password it just masks it.

No comments: