MDauphinais1
asked on
Mask password Inputbox in VBScript
I have a VBScript that prompts users for a username and password and then passes the information to log them into a remote server. Is it possible to mask the password as it is entered into the input box?
ASKER
How do I run it using CScript?
ASKER
I tried this but it didn't work...
Dim oShell
Set oShell = CreateObject("Wscript.Shel l")
forceUseCScript
Sub forceUseCScript()
If Not WScript.FullName = WScript.Path & "\cscript.exe" Then
Set oScriptPW = CreateObject("ScriptPW.Pas sword")
WScript.StdOut.Write "Type password and press the Enter key: "
strPassword = oScriptPW.GetPassword()
WScript.StdOut.WriteLine vbCrLf & "You entered: " & strPassword
WScript.Quit 0
End If
End Sub
Dim oShell
Set oShell = CreateObject("Wscript.Shel
forceUseCScript
Sub forceUseCScript()
If Not WScript.FullName = WScript.Path & "\cscript.exe" Then
Set oScriptPW = CreateObject("ScriptPW.Pas
WScript.StdOut.Write "Type password and press the Enter key: "
strPassword = oScriptPW.GetPassword()
WScript.StdOut.WriteLine vbCrLf & "You entered: " & strPassword
WScript.Quit 0
End If
End Sub
Set objPassword = CreateObject("ScriptPW.Pas sword")
WScript.StdOut.Write "Please enter your password:"
strPassword = objPassword.GetPassword()
Wscript.Echo
Wscript.Echo "Your password is: " & strPassword
To run the above code from cscript, do the following:
1) Paste the above code in a .vbs file and save it (ie: c:\documents and settings\user\desktop\mask .vbs)
2) Open a command prompt and change to the directory you saved the file in step 1 (ie: C:\documents and settings\user\desktop)
3) At the command prompt launch the script using cscript (ie: cscript mask.vbs)
4) This will echo back the password you typed.
Please note, this will only work for Windows XP and WIndows 2003. If you are using other OS's, you'll need to create a .hta to accomplish this. See the following link for more details:
http://www.microsoft.com/technet/scriptcenter/resources/qanda/feb05/hey0204.mspx
WScript.StdOut.Write "Please enter your password:"
strPassword = objPassword.GetPassword()
Wscript.Echo
Wscript.Echo "Your password is: " & strPassword
To run the above code from cscript, do the following:
1) Paste the above code in a .vbs file and save it (ie: c:\documents and settings\user\desktop\mask
2) Open a command prompt and change to the directory you saved the file in step 1 (ie: C:\documents and settings\user\desktop)
3) At the command prompt launch the script using cscript (ie: cscript mask.vbs)
4) This will echo back the password you typed.
Please note, this will only work for Windows XP and WIndows 2003. If you are using other OS's, you'll need to create a .hta to accomplish this. See the following link for more details:
http://www.microsoft.com/technet/scriptcenter/resources/qanda/feb05/hey0204.mspx
Add the following statements at the beginning of the script:
If LCase(Right(Wscript.FullNa me, 11)) = "wscript.exe" Then
strPath = Wscript.ScriptFullName
strCommand = "%comspec% /k cscript " & Chr(34) & strPath & chr(34)
Set objShell = CreateObject("Wscript.Shel l")
objShell.Run(strCommand)
Wscript.Quit
End If
_______________
Nayer Naguib
If LCase(Right(Wscript.FullNa
strPath = Wscript.ScriptFullName
strCommand = "%comspec% /k cscript " & Chr(34) & strPath & chr(34)
Set objShell = CreateObject("Wscript.Shel
objShell.Run(strCommand)
Wscript.Quit
End If
_______________
Nayer Naguib
ASKER
Does this have to use the command prompt? Is there no way to still use the Input box type format?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Set oScriptPW = CreateObject("ScriptPW.Pas
WScript.StdOut.Write "Type password and press the Enter key: "
strPassword = oScriptPW.GetPassword()
WScript.StdOut.WriteLine vbCrLf & "You entered: " & strPassword
_______________
Nayer Naguib