Announcement

Collapse
No announcement yet.

Is it possible to mask password in InputBox without using HTA application?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Is it possible to mask password in InputBox without using HTA application?

    I came across one of Rems previous post in 2007 on VB Script mapping a drive with a username and password.

    Could anyone please advise how do I put a password mask in the code that was provided by Rems below without using HTA:

    ================================================== =========================

    on Error Resume Next

    ' *** variables
    mDrive = "K:"
    strRemoteShare = "\\server\share"
    strUPNsuffix = "@domain.com"

    strPer = "FALSE"

    minUSRnamelength = 2
    minPASSwrdlength = 3


    ' *** InputBox(prompt[,title][,default][,xpos][,ypos][,helpfile,context])
    ' *** & Map drive using the entered credentials

    Set objNetwork = WScript.CreateObject("WScript.Network")
    Set oShell = CreateObject("Shell.Application")

    strUsr = InputBox(vbcrlf& vbcrlf& "Confirm your Username","Enter Your Username",objNetwork.username)
    If Not Len(strUsr) < minUSRnamelength then
    strUsr = Ucase(strUsr) & strUPNsuffix '<--- adds the UPNsuffix to the account
    strPas = InputBox(vbcrlf& "Please enter " & vbcrlf& strUsr & "'s" & vbcrlf& vbcrlf& "email Password:")
    if Not Len(strPas) < minPASSwrdlength then
    Err.Clear
    objNetwork.MapNetworkDrive mDrive, strRemoteShare, strPer, strUsr, strPas
    If Err.Number = 0 Then
    oShell.NameSpace(mDrive).Self.Name = "share name"
    End If
    End If
    End If

    Set oShell = Nothing
    wscript.quit 0


    ' *** How can I mask Passwors Using an InputBox?
    ' http://www.microsoft.com/technet/scr...5/hey0204.mspx
    ' *** How Can I Specify a Window Size for My HTA?
    'http://www.microsoft.com/technet/scriptcenter/resources/qanda/sept05/hey0919.mspx
    ================================================== =========================

    Thank you.

  • #2
    As far as i know there is no way of doing this. InputBox doesn't allow for it hence the workarounds.

    https://blogs.technet.microsoft.com/...g-an-inputbox/

    http://www.robvanderwoude.com/vbstech_ui_password.php

    Comment


    • #3
      Is it possible for you to convert the script to powershell? You can then either use Get-Credential or Read-Host -AsSecureString.
      Regards,
      Jeremy

      Network Consultant/Engineer
      Baltimore - Washington area and beyond
      www.gma-cpa.com

      Comment

      Working...
      X