Sunday, July 21, 2013

Enter username , password in form using batch file / Hide password batch file

Use below code and write into the file, which is ended up with *.bat. Save the file double click on file. After which a form will popup in which you can enter username and password and password is not visible.

@echo off

echo Please enter your user name and password in the entry box...
If not exist %0 goto ERROR
type %0 | find "    " | find /v "Not Me!" > %TEMP%\UserIn.hta
start /w %TEMP%\UserIn.hta

call %TEMP%\UserIn.bat
echo Your user name is %USERNAME%
echo Your password is %PASSWORD%
:: Clean up
del %TEMP%\UserIn.hta
del %TEMP%\UserIn.bat
goto DONE

echo %0 is not the full path and file name
echo for the batch file. You MUST call this
echo batch file with a full path and file name.
goto DONE

:: All HTA code MUST be indented four or more spaces.
    <title>Password Entry</title>
    <script language="vbscript">
        window.resizeTo 250,200
        Sub SaveBatch()
            Set fs = CreateObject("Scripting.FileSystemObject")
            strFile = fs.GetAbsolutePathName(fs.BuildPath(fs.GetSpecialFolder(2), "UserIn.bat"))
            Set ts = fs.OpenTextFile(strFile, 2, True)
            ts.WriteLine "SET USERNAME=" & document.Forms(0).elements("username").value
            ts.WriteLine "SET PASSWORD=" & document.Forms(0).elements("password").value
        End Sub
        User Name:
        <br><input type=text name=username tabindex=1>
        <br><input type=password name=password>
        <br><input type=button language="vbscript" value="OK"
        onclick="SaveBatch : Window.Close">
    <script language=vbscript>


below screen is of popup window


  1. with same batch code my Password Entry popup not open

  2. can u please post / comment ur code

  3. Hello
    How should i modify this script so i have 3 elements: 1 username, second username, and a password (let say for first username). so i can get their value.

    I have added this lines but in the %temp%\UserIn.hta i don't see them. How is this possible :
    ts. WriteLine "SET USERNAME2=" & document.Forms(0).elements("username2").value


    User Name2:
    br input type=text name=username2 tabindex=1

  4. Please do these changes .. it is working fine for me.

    echo Your user name is %USERNAME2% (at line 14)
    ts.WriteLine "SET USERNAME2=" & document.Forms(0).elements("username2").value (at line 42)


    mid Name:
    input type=text name=username2 tabindex=2 (at line 52 , line no's according to after change in file)

    keep in mind that " All HTA code MUST be indented four or more spaces."


web stats