Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I am wondering if it is possible to create a variable in the registry that holds a password "1qaz3edc" and then in the batch file make it match that password up to the one it requests.
Sorry if it makes no sense.

um... not sure what your saying, but you can make a bat file that writes to registry, not sure if you can make it READ from registry thought...
heres an example for editing registry:
echo Windows Registry Editor Version 5.00 >> c:\reg.reg
echo. >> c:\reg.reg
echo [-HKEY_LOCAL_MACHINE\SOFTWARE\SomeStupidFolder] >> c:\reg.reg
regedit -s c:\reg.reg"this bat makes a registry file that delete "SomeStupidFolder" and then run that registry file without any user-confirmation (-s) you can google up how to make .reg files ^^

The easiest way to go would be to add a string value to your HKCU\Environment. Then it'll show up as a variable in your (or any, really) script.

so in a bat file how do you go about recalling this string value from the registry? Sorry im very new to bat.

Reading from registry is a bit complicated if you're new to batch scripts.. and it depends on what operatin system you're using too.
You can take a look at the following 2 links for it.
http://www.robvanderwoude.com/ntreg...
http://www.robvanderwoude.com/reged...I would just save it into a file.
And as we're dealing with passwords, why not encrypt it too.
From http://www.fourmilab.ch/md5/ you can get a free, small command line program that can encrypt a string into md5 encryption.
First save the password into a file, for example, password "cool" to c:\pwdtest.txt
open cmd and type:
md5 -d"cool">"c:\pwdtest.txt"
that will encrypt the word "cool" and save it in the .txt file.And here's the batch example how to login.
@echo off
set /p password=Login:
for /F %%I in (C:\pwdtest.txt) do set correctPWD=%%I
md5 -d"%password%" -c"%correctPWD%"
if "%errorlevel%"=="0" goto correct
if "%errorlevel%"=="1" goto wrong:correct
set password=
echo Your password was correct.
::do some stuff here
goto end:wrong
echo The password "%password%" was wrong.
goto end:end
pause

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |