Computing.Net > Forums > Programming > Bat Password

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Bat Password

Reply to Message Icon

Name: p1ng
Date: August 5, 2008 at 22:22:37 Pacific
OS: XP
CPU/Ram: n/a
Product: n/a
Comment:

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.



Sponsored Link
Ads by Google

Response Number 1
Name: Hans Henrik
Date: August 6, 2008 at 06:00:02 Pacific
Reply:

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


0

Response Number 2
Name: Razor2.3
Date: August 6, 2008 at 17:49:07 Pacific
Reply:

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.


0

Response Number 3
Name: p1ng
Date: August 6, 2008 at 20:05:54 Pacific
Reply:

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


0

Response Number 4
Name: TanelTM
Date: August 9, 2008 at 23:10:14 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Bat Password

.bat passwords www.computing.net/answers/programming/bat-passwords/11297.html

login.bat works w/ W2K not XP www.computing.net/answers/programming/loginbat-works-w-w2k-not-xp/12788.html

File rename in CMD or Bat script www.computing.net/answers/programming/file-rename-in-cmd-or-bat-script/14672.html