Bat file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
Marde
Posts: 2
Joined: 27 Jul 2017 17:24

Bat file

#1 Post by Marde » 27 Jul 2017 17:40

Hi

Can someone help me to create a .bat that makes my cmd ask for a login and password when the User or anyone else open it ? (is this possible?).

If the above isnt possible then a .bat dat makes the "echo" always "on" so that way everytime the cmd needs something, it will ask to the User.

Im using
Windows 8 Single Language
Sublime text editor

Thanks for anyone who read this :)

penpen
Expert
Posts: 2009
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Bat file

#2 Post by penpen » 28 Jul 2017 01:36

This might help you:
http://www.dostips.com/forum/viewtopic.php?f=3&t=6834#p44337

You need to store the linked MD5 Algorithm as "md5.bat".


penpen

Marde
Posts: 2
Joined: 27 Jul 2017 17:24

Re: Bat file

#3 Post by Marde » 28 Jul 2017 11:41

Ty ^^ i will study this :)

Markk786
Posts: 2
Joined: 31 Jul 2017 17:54

Re: Bat file

#4 Post by Markk786 » 31 Jul 2017 17:57

Thank you.......that was something I didn't know..

NorfolkBatch
Posts: 10
Joined: 03 Aug 2017 22:49

Re: Bat file

#5 Post by NorfolkBatch » 04 Aug 2017 05:34

Put this at the begining of the login section

Code: Select all

@echo off
color 4f
cls
set "psCommand=powershell -Command "$pword = read-host 'Enter Password' -AsSecureString ; ^
     $BSTR=[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pword); ^
           [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)""
for /f "usebackq delims=" %%p in (`%psCommand%`) do set password=%%p
if "%password%"=="Welcome" goto m
goto X
:X
cls
echo INCORRECT PASSWORD
echo ACCESS DENIED
pause
exit

:M
echo Welcome
Pause
cls
exit


Where the Password is Welcome put what you want the password to be

Kind Regards

NorfolkBatch
Posts: 10
Joined: 03 Aug 2017 22:49

Re: Bat file

#6 Post by NorfolkBatch » 04 Aug 2017 09:04

and to hide the code compile the batch file into an exe file using batch to exe software that way no one can change the password or view it for that matter.

Hope this helps someone

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Bat file

#7 Post by aGerman » 04 Aug 2017 09:38

NorfolkBatch wrote:compile the batch file

Batch code can't be compiled. Bat2Exe programs just pack the script into something like a self-extracting archive or an installer. It has to be extracted in order to be executable.

NorfolkBatch wrote:no one can change the password or view it

That's wrong. At least during runtime you will find your original code somewhere in the Temp folder. (Besides of all the other possible side effects that I wrote a hundred times before.)

Steffen

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Bat file

#8 Post by ShadowThief » 04 Aug 2017 15:55

NorfolkBatch wrote:and to hide the code compile the batch file into an exe file using batch to exe software that way no one can change the password or view it for that matter.

Hope this helps someone

If you're storing your passwords in plaintext, you're doing it wrong.
Salt and hash your passwords

NorfolkBatch
Posts: 10
Joined: 03 Aug 2017 22:49

Re: Bat file

#9 Post by NorfolkBatch » 05 Aug 2017 00:41

Here is the site site to visit, http://www.f2ko.de/en/b2e.php
Last edited by NorfolkBatch on 05 Aug 2017 01:05, edited 1 time in total.

NorfolkBatch
Posts: 10
Joined: 03 Aug 2017 22:49

Re: Bat file

#10 Post by NorfolkBatch » 05 Aug 2017 00:53

aGerman wrote:
NorfolkBatch wrote:compile the batch file

Batch code can't be compiled. Bat2Exe programs just pack the script into something like a self-extracting archive or an installer. It has to be extracted in order to be executable.

NorfolkBatch wrote:no one can change the password or view it

That's wrong. At least during runtime you will find your original code somewhere in the Temp folder. (Besides of all the other possible side effects that I wrote a hundred times before.)

Steffen


Incorrect it does not store the password it simply refers it it in the code nothing shows at run-time check it out

NorfolkBatch
Posts: 10
Joined: 03 Aug 2017 22:49

Re: Bat file

#11 Post by NorfolkBatch » 05 Aug 2017 00:58

ShadowThief wrote:
NorfolkBatch wrote:and to hide the code compile the batch file into an exe file using batch to exe software that way no one can change the password or view it for that matter.

Hope this helps someone

If you're storing your passwords in plaintext, you're doing it wrong.
Salt and hash your passwords


How it works is that it is written to the code inside the batch file then converted to a exe file which hides the code as exe files can not show the code.

so when run it looks for the code inside the batch file, Now i don't claim to have written the code but I know it works I have been writing code for a long time now, and have learned much about batch files as it was my Favorited subject I personally have written the ultimate batch file and it does everything you could possible what it to do. I love to learn new things and that is why I am passionate about the subject as I understand it so well

Kind Regards

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Bat file

#12 Post by ShadowThief » 05 Aug 2017 03:14

NorfolkBatch wrote:
aGerman wrote:
NorfolkBatch wrote:compile the batch file

Batch code can't be compiled. Bat2Exe programs just pack the script into something like a self-extracting archive or an installer. It has to be extracted in order to be executable.

NorfolkBatch wrote:no one can change the password or view it

That's wrong. At least during runtime you will find your original code somewhere in the Temp folder. (Besides of all the other possible side effects that I wrote a hundred times before.)

Steffen


Incorrect it does not store the password it simply refers it it in the code nothing shows at run-time check it out

But if the script is open long enough for a user to find it (like if the script asks for the user to input a password, for example), the original script can be found in the Temp folder and if you're storing the password in plain text behind an exe converter, it can easily be seen.

Image

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Bat file

#13 Post by aGerman » 05 Aug 2017 04:18

NorfolkBatch wrote:Incorrect

Nope. I told you how it works and ShadowThief already posted a screenshot. As long as you have commands in your code that wait for user interaction (like SET /P, CHOICE, PAUSE, ...) you have all the time in the world to search and find it on your hard drive (and usually you will find it in the Temp folder). I checked it out a hundred times. Furthermore you don't think of all the drawbacks and side effects caused by the fact that the script is executed in a different folder, caused by the fact that it is executed in WOW64 mode (on 64 Bit machines), caused by the fact that antivirus software might consider the created exe file as False Positive, etc.

Steffen

NorfolkBatch
Posts: 10
Joined: 03 Aug 2017 22:49

Re: Bat file

#14 Post by NorfolkBatch » 05 Aug 2017 12:03

OK I am no longer wasting any more time on this subject you clearly don't understand code here and are to ignorant and uneducated to understand how it works have it your way but the code works and well in my opinion noticed you cant answer any real batch coding questions here as I suspected you don't understand nothing about batch scripting.

Rant Over

By

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Bat file

#15 Post by ShadowThief » 05 Aug 2017 12:53

Obvious troll is obvious

Locked