Page 1 of 1
Adding login requirements when running the batch
Posted: 24 Jul 2012 11:07
by mr_wizard
Hey folks, just looking for the syntax for adding a login requirement inside the batch. I want to restrict the allowed login to 1 technician on our domain, and we all have admin privilages. Ideas?
Re: Adding login requirements when running the batch
Posted: 24 Jul 2012 11:11
by foxidrive
Which batch?
Restricting to one tech can't be done if you all have admin privs. Anyone can find the file and look inside to see any password you might put in it.
You could compile the batch file but IMO batch compilers typically just execute an extracted copy of the bat file from a temp folder, and so that isn't secure either.
Re: Adding login requirements when running the batch
Posted: 24 Jul 2012 12:37
by mr_wizard
Dang, duly noted. Was hoping there was some internal encryption command that can read / scramble a password.
Re: Adding login requirements when running the batch
Posted: 26 Jul 2012 13:38
by Notelek_Labs
HOLD ON! I HAVE THE SOLUTION!
Code: Select all
@echo off
color 47
:start
set /p user=Enter your password
if '%user%'=='12345' GOTO pass
if NOT '%user%'=='12345' GOTO invalidu
:pass
cls
set /p pass=Enter your password
if '%pass%'=='12345' GOTO correct
if NOT '%pass%'=='12345' GOTO invalid
:invalid
cls
echo Invalid password
pause
GOTO start
:invalidu
cls
echo Invalid Username
pause
GOTO start
:correct
cls
echo Welcome back %user%!
start "" /b "example.exe"
Than, Use a batch compiler (google it) so that you can't see the code!
Re: Adding login requirements when running the batch
Posted: 26 Jul 2012 13:58
by Squashman
That is just pseudo security! Even with the batch compiler hiding it. People can still find the batch file once they execute the compiled exe. Just like Foxidrive already stated.
Re: Adding login requirements when running the batch
Posted: 27 Jul 2012 03:13
by SMAndy
Could you not just use Windows Security to limit the people that can run it? Put the file in a hidden share that only the required user has access to, or explicitly deny access to everyone that shouldn't be able to run it? Once you're the owner of the file, you could deny "take ownership" on everyone, then just implicitly deny access to all else to do with it.
Not security in the scripting sense of it, but it would make it secure.