0

does anyone have an idea how to mask the InputBox in VBScript without using html (work security issues)? I'm using windows 10. Thank you very much, any help is greatly appreciated.

  • What do you mean by "mask input"? – iBug Jan 11 '18 at 03:20
  • 1
    I think he means masking just as in the password fields where the user enters the password but because it is masked with `*`, it is not visible to others. He needs the same thing for an Inputbox in vbscript – Gurmanjot Singh Jan 11 '18 at 03:27
  • 1
    [For Reference](https://blogs.technet.microsoft.com/heyscriptingguy/2005/02/04/how-can-i-mask-passwords-using-an-inputbox/) – Gurmanjot Singh Jan 11 '18 at 03:51

2 Answers2

4

In VBScript you essentially have 2 options for masked input:

  • Using the console and a ScriptPW.Password object:

    Set oInput = CreateObject("ScriptPW.Password")
    WScript.StdOut.Write "Enter password: "
    pw = oInput.GetPassword
    
  • Using a custom HTML dialog.

[Source]

Masking input in the builtin InputBox dialog is not possible.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
1

ES_PASSWORD Displays an asterisk (*) for each character typed into the edit control. This style is valid only for single-line edit controls. Windows XP: If the edit control is from user32.dll, the default password character is an asterisk. However, if the edit control is from comctl32.dll version 6, the default character is a black circle.

To change the characters that is displayed, or set or clear this style, use the EM_SETPASSWORDCHAR message.

So set the style for the contained edit box to password.

There is some C source code here

MSDN - How to Create a Single Line Edit Control


Run batch script as admin during Maven build (gives a good example of a wrapped VBScript that can be used for this purpose).

user692942
  • 16,398
  • 7
  • 76
  • 175
ACatInLove
  • 530
  • 2
  • 5
  • So how are they supposed to do that from VBScript exactly? – user692942 Jan 11 '18 at 07:14
  • 1
    You can't do it from VBScript but you can compile the VBScript with the added API call using C:\Windows\Microsoft.NET\Framework\v4.0.30319\vbc the VB.NET compiler. Just delete all instances of the keyword `set` and wrap with 5 lines of wrapper module code. See https://stackoverflow.com/questions/47902221/run-batch-script-as-admin-during-maven-build/47913331#47913331 – ACatInLove Jan 11 '18 at 08:01
  • One of the prime skills for basic programmers is to read C code as so many samples are in C or a derived language. This is especially true for API calls. – ACatInLove Jan 11 '18 at 08:46
  • 1
    The point was regardless of your assumption, the answer wasn't clear at least now there is some context. Assuming everyone who uses VBScript will understand C is a bit pompous. – user692942 Jan 11 '18 at 09:06
  • But it tells you the API calls or COM calls. And that text is identical across all languages. It allows you to know what to look up in help. – ACatInLove Jan 11 '18 at 09:08