@echo off
for /f "tokens=* skip=5" %%a in (%0.cmd) do echo %%a >>_.vbs
cscript /nologo _.vbs
del _.vbs
goto :eof
Set op = CreateObject("ScriptPW.Password")
WScript.Echo "Please enter your password:"
strPassword=op.GetPassword():Wscript.Echo
Wscript.Echo "Your password is: " & strPassword
@echo off
type %0.cmd | find ":" | find /v "find /v">_.vbs
cscript /nologo _.vbs
del _.vbs
:Set op = CreateObject("ScriptPW.Password")
@echo off
echo Set ops = CreateObject("ScriptPW.Password") >_.vbs
echo WScript.Echo "Enter password:" >>_.vbs
echo strPassword = ops.GetPassword() >>_.vbs
echo Wscript.Echo >>_.vbs
echo Wscript.Echo "Your password is: " ^& strPassword >>_.vbs
cscript /nologo _.vbs
del _.vbs
pause
"Marco Maier Said" <full...@yahoo.it> wrote in message
news:1f279zfj...@MRC.MIR.SID.75...
Cool, using the vbscript ":" statement delimiter that happens to be the
batch label prefix!
But I get "The system cannot find the file specified.", unless I type the
name of the batch file without the extension. Suggest you make this
foolproof by using:
type "%~dpnx.cmd" | find ":" | find /v "find /v">_.vbs
/Al
I agree with Al. However, I personally prefer "%~fs0". Also using
Findstr might be worth looking into. For example:
findstr /B ":" %~sf0 >_.vbs
I also tried the script with double colons and it worked just the
same. I also used ": " which also worked fine. This would help me
because I'm so used to using "::" to comment out lines, which caused
syntax errors in the VBscript because "::@echo off" is not valid
VBscript syntax. ; )
Please forgive my plagiarizing, and thank you very much for
contributing to a.m.b.nt.
@echo off
findstr /B ": " %~sf0 >_.vbs
cscript /nologo _.vbs
del _.vbs
: Set op = CreateObject("ScriptPW.Password")
: WScript.Echo "Please enter your password:"
: strPassword=op.GetPassword():Wscript.Echo
: Wscript.Echo "Your password is: " & strPassword
Thanks
Clay Calvert
CCal...@Wanguru.com
Replace "W" with "L"
>I agree with Al. However, I personally prefer "%~fs0". Also using
>Findstr might be worth looking into. For example:
>
>findstr /B ":" %~sf0 >_.vbs
Make that:
findstr /B /C:": " %~sf0 >_.vbs
>I also tried the script with double colons and it worked just the
>same. I also used ": " which also worked fine. This would help me
>because I'm so used to using "::" to comment out lines, which caused
>syntax errors in the VBscript because "::@echo off" is not valid
>VBscript syntax. ; )
>
>Please forgive my plagiarizing, and thank you very much for
>contributing to a.m.b.nt.
@echo off
findstr /B /C:": " %~sf0 >_.vbs
cscript /nologo _.vbs
del _.vbs
: Set op = CreateObject("ScriptPW.Password")
: WScript.Echo "Please enter your password:"
: strPassword=op.GetPassword():Wscript.Echo
: Wscript.Echo "Your password is: " & strPassword
Clay Calvert
> But I get "The system cannot find the file specified.", unless I type the
> name of the batch file without the extension. Suggest you make this
> foolproof by using:
>
> type "%~dpnx.cmd" | find ":" | find /v "find /v">_.vbs
^^^^^^^^^^
That should have been "%~dpnx0" or "%~f0".
--
Todd Vargo (remove hyphen to reply by email)
Actually, I thought your second suggestion was what I had posted - not sure
where the .cmd came from...
/Al
> @echo off
> findstr /B /C:": " %~sf0 >_.vbs
> cscript /nologo _.vbs
> del _.vbs
>: Set op = CreateObject("ScriptPW.Password")
>: WScript.Echo "Please enter your password:"
>: strPassword=op.GetPassword():Wscript.Echo
>: Wscript.Echo "Your password is: " & strPassword
Thanks for the notes , it worked on my PC.
This version works as well:
@echo off
findstr "^:" %~s0 >_.vbs
cscript /nologo _.vbs & del _.vbs
: Set op = CreateObject("ScriptPW.Password")
: WScript.Echo "Please enter your password:"
: strPassword=op.GetPassword():Wscript.Echo
: Wscript.Echo "Your password is: " & strPassword
--
Marco
52) How can I enter a password into a variable without echoing it?
This is a task that is best done with the help of Visual Basic
program which the actual CMD script creates. Note that the resultant
password variable is made available to the CMD script since this is
a CMD, not a WSH FAQ.
@echo off & setlocal enableextensions
:: Build a Visual Basic Script
findstr "'VBS" "%~f0"|findstr /v "findstr" > tmp$$$.vbs
:: Run it with Microsoft Windows Script Host Version 5.6
cscript //nologo tmp$$$.vbs
:: Call the command line script wchich the script host built
call tmp$$$.cmd
:: Clean up
for %%f in (tmp$$$.vbs tmp$$$.cmd) do if exist %%f del %%f
:: Demonstrate the result
echo The entered password was %PassWord%
endlocal & goto :EOF
'
'The Visual Basic Script
Set WshShell = WScript.CreateObject("WScript.shell") 'VBS
Set WshPass = WScript.CreateObject("ScriptPW.Password") 'VBS
WScript.Echo "Password: " 'VBS
Password=WshPass.GetPassWord() 'VBS
WshShell.run "cmd /c echo @set PassWord=" & PassWord & ">tmp$$$.cmd" 'VBS
All the best, Timo
--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:t...@uwasa.fi <http://www.uwasa.fi/~ts/> ; FIN-65101, Finland
Useful script files and tricks ftp://garbo.uwasa.fi/pc/link/tscmd.zip