Hiding password in batch file

April 2, 2010 at 16:50:34
Specs: Windows XP, any
hi,
i have batch file for hiding folder, but the
problem is at the time of entering password it
shows what we write.. i just want to hide my
password while typing... pls can anyone help
me.
here is my code
cls
@ECHO OFF
title Folder System
if EXIST "Control Panel.{21EC2020-3AEA-
1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST System goto MDLOCKER
:CONFIRM

echo Are you sure u want to Lock the System
(Y/N)
set/p "cho=>"
if %cho%==Y goto LOCK
if %cho%==y goto LOCK
if %cho%==n goto END
if %cho%==N goto END
echo Invalid choice.
goto CONFIRM
:LOCK
ren System "Control Panel.{21EC2020-3AEA-
1069-A2DD-08002B30309D}"
attrib +h +s "Control Panel.{21EC2020-3AEA-
1069-A2DD-08002B30309D}"
echo Folder locked
goto End
:UNLOCK
echo Enter password to Unlock folder
set/p "pass=>"
if NOT %pass%==abcd1234 goto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-
1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-
A2DD-08002B30309D}" System
echo Folder Unlocked successfully
goto End
:FAIL
echo Invalid password
goto end
:MDLOCKER
md System
echo System created successfully
goto End
:End

thankyou


See More: Hiding password in batch file

Report •


#1
April 2, 2010 at 17:19:27
Might have a look here - similar question with two solutions.

http://www.computing.net/answers/pr...


Report •

#2
April 2, 2010 at 23:26:13
this requires debug-assistance, but it seems to work:
:: edit: suggest making this top part a standalone installation script, save it and run it one time.
::--------- installer script
@goto :100
e 100 BF 80 00 57 B4 07 CD 21 AA 3C 0D 75 F7 5E AC 3C
e 110 0D 74 08 88 C2 B4 02 CD 21 EB F3 CD 20
nblank.com
rcx
20
w
q
:100
if exist blank.com goto :ok
debug < %0.bat >nul 2>nul
:ok
::--------- END of installation script. now test it:
:: test script:
@echo off & setlocal
::---- this is the usage part
for /f %%a in ('blank') do set pw=%%a
cls
::---- the rest is just window-dressing
echo.here is the secret password, DON'T TELL!:
pause
set pw
::--- end script: %pw% is your password in var. pw.
:: ps:
i keep thinking there must be a simple way to utilize "type-ahead" coupled with a medium-slow command to do this, but i can't put it together. this almost works except for the obvious overhead:
copy /b *.txt con
set /p xx=:
cls
echo.DID YOU SEE THAT! HIS PASSWORD IS:
echo nah nah, you didn't see it!
pause
echo.%xx%
::-------
just needs the right command, preferably one that terminates with something from the keyboard, but thats the rub...
this so trivial it bogs the mind, but i get obsessed sometimes!

Report •

#3
April 3, 2010 at 03:22:44
Thank you Viddywell and Nbrane for ur reply.. Nbrane i tried ur
code, but im not able to do it. I dont know much about coding.
can u pls fix ur code in my, because i tried and was not able to
do!! Thankyou for ur co-operation

Report •

Related Solutions

#4
April 3, 2010 at 07:35:43
In a C-compiler, it's pretty simple to cover typed letters, but setting as a variable may be harder

Report •

#5
April 3, 2010 at 12:06:32
i forgot to mention, the code as i've written it, lines 1 to 13 has to be placed at the very top of your batchscript. everythinge except the "for" loop and "cls". You might prefer to make it (lines 1-13) a called subroutine or a one-time "installation", because that's what those lines do: install the small "blank.com" program. I'll edit my script to show the two parts. make lines 1-13 into a separate batchfile and call it "makeblnk.bat" for example. then execute "makeblnk".
Now you have blank.com available for your program to use,
(be sure to put it into the path where your program(s) can find it.) then, use it like this:
UNLOCK
echo Enter password to Unlock folder
set/p "pass=>"
for /f %%a in ('blank') do set pass=%%a
cls
if NOT %pass%==abcd1234 goto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-
1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-
A2DD-08002B30309D}" System
echo Folder Unlocked successfully
goto End
::-------
ps Ouch! i forgot to put "cls" into my original code. will edit to do so now. sorry
@tvc: yeah, generally for another program (C)to pass it into a variable, it needs to go through stdout, which means it needs to go onto the screen. you could, however, use a tempfile to pass it, but that makes the code (in the batchscript) somewhat more cumbersome. not a lot though. my code could also do that:
echo password:
blank > tempfile
for /f %%a in tempfile do set passw=%%a
then you don't need the cls anymore, so your screen content doesn't get trashed every time.

Report •

#6
April 4, 2010 at 20:21:00
codes for "new and improved" not requiring screen blank:
@goto :start
e100 B4 03 CD 10 52 B9 00 00 BF 80 00 57 B4 07 CD 21
e110 AA 41 3C 0D 75 F6 5E AC 3C 0D 74 08 88 C2 B4 02
e120 CD 21 EB F3 5A 80 EE 01 CD 10 B8 20 0A CD 10 CD 20
rcx
40
w
q
:start
if exist eraser.com goto :installed
debug eraser.com < %0.bat > nul
:installed
for /f %%a in ('eraser') do set pw=%%a

Report •


Ask Question