Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to hide passwords (XP)

137 views
Skip to first unread message

Marco Maier Said

unread,
Jan 25, 2004, 6:09:16 AM1/25/04
to
Run from the command prompt:

@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

Marco Maier Said

unread,
Jan 25, 2004, 4:42:35 PM1/25/04
to
A variation on the theme:

@echo off
type %0.cmd | find ":" | find /v "find /v">_.vbs


cscript /nologo _.vbs
del _.vbs

:Set op = CreateObject("ScriptPW.Password")

Argus Rogue

unread,
Jan 25, 2004, 6:48:58 PM1/25/04
to
Here's one that I got from this GROUP that works great

@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...

Al Dunbar

unread,
Jan 25, 2004, 7:19:22 PM1/25/04
to

"Marco Maier Said" <full...@yahoo.it> wrote in message
news:1gx80n1f8ox9r$.mms@MRC.MIR.SID.75...

> A variation on the theme:
>
> @echo off
> type %0.cmd | find ":" | find /v "find /v">_.vbs

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

Clay Calvert

unread,
Jan 25, 2004, 7:46:42 PM1/25/04
to
On Sun, 25 Jan 2004 21:42:35 GMT, Marco Maier Said <full...@yahoo.it>
wrote:

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"

Clay Calvert

unread,
Jan 25, 2004, 7:55:19 PM1/25/04
to
On Sun, 25 Jan 2004 19:46:42 -0500, Clay Calvert
<ccal...@Wanguru.com> wrote:

>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

Todd Vargo

unread,
Jan 25, 2004, 9:44:38 PM1/25/04
to

"Al Dunbar" wrote:

> 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)

Al Dunbar

unread,
Jan 26, 2004, 12:12:06 AM1/26/04
to

"Todd Vargo" <todd_...@nccw.net> wrote in message
news:bv1v1g$n6u6a$4...@ID-25025.news.uni-berlin.de...

>
> "Al Dunbar" wrote:
>
> > 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".

Actually, I thought your second suggestion was what I had posted - not sure
where the .cmd came from...

/Al


Marco Maier Said

unread,
Jan 26, 2004, 5:00:54 AM1/26/04
to
Clay Calvert wrote in message
<news:e9p81099ddddoohoc...@4ax.com> :

> @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

Timo Salmi

unread,
Jan 31, 2004, 5:50:47 AM1/31/04
to
DRAFT

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

0 new messages