Reputation: 1897
I need to prompt for a username and password from a batch script subroutine and I have the following requirements:
I'm assuming that I may need to use VBscript, which I can easily create from within the batch script and then delete afterward. I did find this link, with two different VBScript options, but the first one violates requirement 1 (console based), and the second violates requirement 3 (default IE settings aren't allowing dynamic content these days). Any other ideas?
Upvotes: 1
Views: 2978
Reputation: 2144
Is using Powershell out of the question?
You can use Get-Credential to prompt for authentication.
$Credentials = Get-Credential Domain\UserName
Edit:
Another option if distributing this application is to just put the prompt for a username and password in the installer. You could do this in an MSI, but it is probably a lot more overhead than you'd want. You could instead use NSIS and prompt for the info in the installer wizard. NSIS is self-contained and would run on all the OS's you specified.
Upvotes: 1
Reputation: 8459
HTML Applications might work for you. You could create a simple page with an <input type="password" />
control. I can't think of a good way to get the password from the HTA back to the batch file, though, other than writing the password to a temporary file, or maybe a registry key.
Upvotes: 1
Reputation: 40736
I would write a native C++ or Delphi application that consists of a single dialog with a password input field.
Compiling this to a single executable and returning the entered value to the calling process, the batch script could ship with the executable in the same folder and use it to query for the password.
If .NET is an option, write a WindowsForms application instead of native C++ (for speed of development)
Upvotes: 1