You can call this batch-HTA-VBScript hybrid file (GUI Login Prompt):
<!-- :
:: LoginGUI.bat | Wasif Hasan | Sep 2020
:: This is a Batch-HTA-VBScript hybrid that will show a GUI window to login
:: Save it as a .bat file and run it in your other batch files
:: and returns the username and password as a result (to STDOUT) (in "username;password" format)
:: If you enter no password in the dialog it will show an error message box and persist
:: Arguments: "BatchFilePath" "prompt (To Show beside the password box)" BoolAllowBlankUsername BoolAllowBlankPassword
:: Default prompt is "password"
@echo off & setlocal EnableDelayedExpansion
if "%*"=="" (
for /f "tokens=* delims=" %%a in ('echo "Password:" False False ^| mshta.exe "%~f0"') do set "pass=%%a"
) else (
for /f "tokens=* delims=" %%a in ('echo %* ^| mshta.exe "%~f0"') do set "pass=%%a"
)
echo !pass! & exit /b 0
-->
<!DOCTYPE html>
<html>
<head>
<title>Password box</title>
<hta:application
applicationName="Password box"
border="thin"
maximizeButton="no"
minimizeButton="no"
showinTaskbar="no"
scroll="no"
singleInstance="yes"
contextMenu="no"
selection="no"
/>
<script type="text/vbscript">
Sub Window_OnLoad()
Dim fso2, strPrompt, dblQuote
window.resizeTo 320,180
Set fso2 = CreateObject("Scripting.FileSystemObject").GetStandardStream(0)
strPrompt = fso2.ReadLine
dblQuote = Chr(34)
strPromptX = Split(strPrompt," ")
strPrompt = strPromptX(0)
strPrompt = Replace(strPrompt, dblQuote, "")
Document.All.prompt.innerHTML = strPrompt
document.All.username.Focus
End Sub
Sub Validate()
Dim fso, GetPassword, GetUsername
GetPassword = Document.All.Password.Value
GetUsername = Document.All.username.Value
If GetPassword = "" Then
If Not allowBlankPassword = True Then
MsgBox "Please enter a password!",48,"Password box"
End If
ElseIf GetUsername = "" Then
If Not allowBlankUsername = True Then
MsgBox "Please enter a username!",48,"Password box"
End If
Else
Set fso = CreateObject("Scripting.FileSystemObject").GetStandardStream(1)
window.Close(fso.write(GetUsername & ";" & GetPassword))
End If
End Sub
</script>
</head>
<body style="background-color:lightblue;font-family:Tahoma;">
<div align="center">
<span id="username_l">Username:</span>
<input type="text" size="20" id="username" /><br /><br />
<span id="prompt">Password:</span>
<input type="password" size="20" id="Password" />
<p><input type="button" value="Login" onClick="Validate()" /></p>
</div>
</body>
</html>