Articles

Username and Password in cmd

September 8, 2006 at 16:23:15
Specs: Windows Xp Home, Can't Remember 256Mb Ram

Hi I'm pretty new at batch files and what I want to do is to protect a certain .exe file from other users of my computer.
I think I need something like this...

@echo off
pause
need to set username and password here
start programme

Can somebody please help me?
Thanks in advance


See More: Username and Password in cmd

Report •


#1
September 9, 2006 at 07:25:53

You can verify user&the password in a batch, but you cant really protect the file. The user can just locate the file and run it without the batch.. Anyway, heres the code


:--
@echo off

:EnterUsr
cls
set /p usr=Enter username:
if not "%usr%" equ "somename" goto UsrError

:EnterPass
cls
echo User: %usr%
set /p pass=Enter Password:
if not "%pass%" equ "mypassword" goto PassError


start yourfile.exe
exit


::Exceptions
:UsrError
echo Wrong username & pause & goto EnterUsr

:PassError
echo Wrong password, please try again & pause & goto EnterPass


Report •

#2
September 9, 2006 at 07:28:04

Hmm, something went wrong during submitting. Just remove the
:--
from the code.

Report •

#3
September 16, 2006 at 09:17:34

I would recommend that if you are using XP (hopefully you are otherwise this will be impossible to do) you can right click the folder or file itself and open up the security window. From there, decide which users are allowed to access it (Hopefully, they've been set up with their own profiles) and make sure they are not part of the administrators group (Otherwise they can just change the file permissions). Shr0Om is right, the batch file would only help if thats the only thing they knew existed, but then if they opened the batch file and saw where it was pointing to, then they could just open that file by going directly there and opening it.

Report •

Related Solutions


Ask Question