how to hide the password accepted in input

April 14, 2010 at 06:29:25
Specs: Windows xp
Dear all,

please i need ur help in this little issue in windows batch programming,

does somebody knows how to hide a password accepted in input so it does not appear to the screen or it appears as special characters like**.

thank u

See More: how to hide the password accepted in input

April 14, 2010 at 06:36:15
With pure batch, no

Helping others achieve escape felicity


Report •

April 14, 2010 at 09:21:14
someone else wanted that not too far back. response #6 was the best i could do (the other one worked too, but it erases your whole screen.

Report •

April 26, 2010 at 09:16:43
Could probably do this in assembler. That would mean a call-out to an .exe, unless you code the assembler proc within batch on the fly using debug, then call the produced executable from within the dos code - klunky!

Report •

Related Solutions

April 26, 2010 at 11:07:42
And it's incompatible with x64 systems!

I think the MS recommended scripting method is to use VBScript and IE. Or use POWERSHELL!, but that's only standard on Win7 and (presumably) up.

Report •

April 26, 2010 at 16:28:00
i made a newer one, it puts indicators, but it won't handle backspacing:
@goto :aa
e100 B4 07 CD 21 3C 0D 74 1B 88 C2 B4 02 CD 21 B9 01
e110 00 B8 2A 0A CD 10 B4 03 CD 10 80 C2 01 B4 02 CD
e120 10 EB DD B4 4C CD 21
debug < %0.bat
::demo: >> %0.bat
type %0.bat
goto :eof

Report •

April 27, 2010 at 01:53:50
Razor, you said "use VBScript and IE" - can you tell me how to use IE for this purpose?

To the original poster: in Windows XP, and only in XP, you can use this batch file to get a password:

@echo off
echo wscript.echo CreateObject("ScriptPW.Password").GetPassword() > %0:GetPassword.vbs
for /f "delims=" %%a in ('cscript /nologo %0:GetPassword.vbs') do set password=%%a
echo Your password is: %password%

(If you think having a VB script as an alternate data stream attached to a batch file is too flash for your own good, then just keep them as two separate files.)

Unfortunately, Vista and later have taken a backward step and removed the ScriptPW.Password object.

Report •

April 27, 2010 at 04:07:10
klint: can you tell me how to use IE for this purpose?
I could, but I'd rather just link to this TechNet article.

That example shows you a two file method. It can be done in a single file, but it's not as pretty:

Dim done, ie
Const notDone = 0
Const okDone = 1
Const cancelDone = 2
WScript.Quit Main

Function Main
  WScript.Echo "I never would have guessed your password was " _
   & GetPwd("What's you're super-secret password?")
End Function

Function GetPwd(sPrompt) 'As String
  done = notDone
  GetPwd = ""
  Set ie = WScript.CreateObject("InternetExplorer.Application", "IE_")
  With ie
    .Navigate "about:blank" 
    .ToolBar = False
    .StatusBar = False
    .Width = 400
    .Height = 250 
    .Left = 300
    .Top = 200
    .Document.body.innerHTML = sPrompt _
     & "
<form id=""f""><input type=""password"" id=""pwd"" size=40>
" _
     & "<input type=""submit"" value=""OK"">&nbsp;&nbsp;&nbsp;" _
     & "<input type=""button"" value=""Cancel"" id=""can""></form>" = "hidden"
   End With
  ie.Document.getElementByID("f").onSubmit = GetRef("IE_Submit")
  ie.Document.getElementByID("can").onClick = GetRef("IE_Cancel")
  ie.Visible = True
  Do Until done
    WScript.Sleep 250
  If done = okDone Then
    GetPwd = ie.Document.getElementByID("pwd").Value
  End If
  Set ie = Nothing
End Function

Function IE_Submit
  done = okDone
  IE_Submit = False
End Function
Sub IE_Cancel
End Sub
Sub IE_Quit 
  done = cancelDone
End Sub

Report •

April 27, 2010 at 14:48:52
I would think such questions (the initial question in this thread) is perfectly suited to be handled by simple C-programming. You can even decide to restrict on characters, convert upper and lower to either, and the code needed does not have to be complex even.

Report •

Ask Question