Adding login requirements when running the batch

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
mr_wizard
Posts: 14
Joined: 11 Jul 2012 12:46

Adding login requirements when running the batch

#1 Post by mr_wizard » 24 Jul 2012 11:07

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?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Adding login requirements when running the batch

#2 Post by foxidrive » 24 Jul 2012 11:11

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.

mr_wizard
Posts: 14
Joined: 11 Jul 2012 12:46

Re: Adding login requirements when running the batch

#3 Post by mr_wizard » 24 Jul 2012 12:37

Dang, duly noted. Was hoping there was some internal encryption command that can read / scramble a password.

Notelek_Labs
Posts: 16
Joined: 22 Jul 2012 20:26

Re: Adding login requirements when running the batch

#4 Post by Notelek_Labs » 26 Jul 2012 13:38

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!

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Adding login requirements when running the batch

#5 Post by Squashman » 26 Jul 2012 13:58

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.

SMAndy
Posts: 8
Joined: 28 May 2012 03:23

Re: Adding login requirements when running the batch

#6 Post by SMAndy » 27 Jul 2012 03:13

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.

Post Reply