Hide user input on DOS command prompt
-
24 июня 2010 г. 5:38I have a batch file which prompts for User Name and Pass word to begin the command line execution. I want to hide the Password while user enters it. I had googled for the same, but of no use. Can anybody help me. This is very urgent.............................!!!!!!!!!!
Все ответы
-
24 июня 2010 г. 6:14Модератор
Hi
Have you tried creating a .hta and using password field (masked input)? You could then attach the script\batch file to a function on the .hta's submit button which calls the command using the .hta's password as a variable.
Cheers Matt :)
- Предложено в качестве ответа hoeyshane 16 августа 2010 г. 23:04
- Помечено в качестве ответа IamMredMicrosoft Employee, Owner 17 августа 2010 г. 16:23
-
24 июня 2010 г. 6:38
Another way would be to use runas to call the batch file. The target batch file would then be running in the context of the user thou.
Shane
Shane Hoey psugbne.org | Powershell Usergroup Brisbane- Предложено в качестве ответа hoeyshane 16 августа 2010 г. 23:04
- Помечено в качестве ответа IamMredMicrosoft Employee, Owner 17 августа 2010 г. 16:23
-
24 июня 2010 г. 7:17
I have found this on net, and was running fine on my local machine. but on server it gives error.
Code :
@echo off
echo Password:
call :GetPassword p
if "%p%"=="123456" (echo - Yes) else echo - No
pause
goto :eof:GetPassword
pushd %tmp%
>p.vbs echo WSH.Echo CreateObject("ScriptPW.Password").GetPassword
for /f %%a in ('cscript -nologo p.vbs') do set %1=%%a
del p.vbs
popdError :
Password:
C:\Users\AppData\Local\Temp\1\p.vbs(1, 1) Microsoft VBScript
runtime error: ActiveX component can't create object: 'ScriptPW.Password'Can you help me to solve this error. I have activated scrrun.dll from system32.
-
24 июня 2010 г. 12:41Модератор
That object requires the scriptpw.dll, not scrrun. I believe it was only provided with XP and discontinued for some reason in Vista and beyond. Check the system32 folder for that dll file or the registry for the ScriptPW.Password key. The error message you post suggests that it is not installed on your machine(s).
Without that DLL installed and registered, you will need to use one of the other techniques offered earlier.
Tom Lavedas -
24 июня 2010 г. 14:10Модератор
Hi,
I wrote a command-line tool called EditV32/EditV64 that lets you interactively edit environment variables. It also has a '-m' option that displays '*' instead of characters for masking password input. It's like 'set /p' except it lets you edit existing variables, get password input, and more. It might work for you.
http://www.westmesatech.com/editv.html
HTH,
Bill
- Предложено в качестве ответа hoeyshane 16 августа 2010 г. 23:04
- Помечено в качестве ответа IamMredMicrosoft Employee, Owner 17 августа 2010 г. 16:23
-
24 июня 2010 г. 14:50
scriptname: pwd_invoke.js
var initWindowStyle = 8; // Display window in the current state, active window remains active
var WshShell = WScript.CreateObject("WScript.Shell");
var WshSysEnv = WshShell.Environment("PROCESS");var user = WshSysEnv("USERNAME"); // get current username from environment variable
var arglist = "";
objArgs = WScript.Arguments;
for (i = 0; i < objArgs.length; i++)
{
arglist += objArgs(i)+" ";
}
s = "runas /user:" + user + " " + arglist;
WshShell.Run(s, initWindowStyle);
the batch file is then used for calling cscript
@echo off
rem *** + full command line to pass to RunAs which is called from cscript
start /I cscript pwd_invoke.js //NoLogo myfile.exeHope this gets you somewhere. Admittedly it's a bit rough with multiple command prompt windows, but you can supress those once you get to grips with it.
-
25 июня 2010 г. 2:14Модератор
Hi technogeist2k6,
I'm trying to understand how executing the 'runas' command in a WSH script helps with the original poster's question?
Bill
-
25 июня 2010 г. 8:34
It was also suggested by another poster to perhaps use runas, a more secure way of getting the password. (from a batch file standpoint at least)
But there were some assumptions made, such as the username and password of their windows account.
Wrapping it all up an jscript seemed easier. But not neccesarily clearer.
I had preferred Mr. Beattie's suggestion of using an HTA, but it isn't my thread, or problem. Your first response arrived just before I had a chance to post mine. So I thought, let the guy with the problem choose, and posted another alternative.
-
20 июля 2010 г. 13:02
Hi Sarika09
Just clearing up some older posts, can you mark the best answers so we can close this thread off
cheers
shane
Shane Hoey scriptingdownunder.com | Scripting Downunder psugbne.org | Powershell Usergroup Brisbane -
24 апреля 2012 г. 4:44
How can I set this to after the correct password has been entered run "X" application?
Here is what I have for example:
@Echo off
editv32 -m -p "Enter the password: " pass
if %input%==pass goto 1
1:
Start winword.exe
Exit
it works be it an incorrect password is entered it also works???
-
24 апреля 2012 г. 10:45
Please open a new question as this topic has been cloosed for two years. You are not likely to get an answer and the topic is about something differnt.
¯\_(ツ)_/¯
-
24 апреля 2012 г. 14:58Модератор
@Echo off
editv32 -m -p "Enter the password: " pass
if %input%==pass goto 1Hi,
Look carefully at your code. You are reading user input and storing it in the variable pass, but then you are checking the value of a variable called input.
Bill -
24 апреля 2012 г. 14:59МодераторHe's also failing to provide a failure branch in his procedure (e.g. GOTO :EOF after the IF test).
Tom Lavedas

