make a batch1 call up an specifique line in batch2

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
redhawk
Posts: 7
Joined: 17 Feb 2015 05:52

make a batch1 call up an specifique line in batch2

#1 Post by redhawk » 25 Feb 2015 06:45

batch 1

Code: Select all


:main
@echo off & title Login & cls
echo ========================
echo ------Login Menu========
echo ========================
pause >nul
call db.bat

:lol
goto main
pause


:finish
echo allright this worked out nice
echo now i can finally continue this piece of shit xD
pause



batch2:

Code: Select all

@echo off & title Login & cls & goto usrid

:usrid
ECHO.
set/p usr=Login As:
if %usr%==Eugene goto psw
if %usr%==Toxic goto psw
if %usr%==Plague goto psw
if %usr%==Jason goto psw
goto usrid


:psw
CLS
ECHO Enter autherization code:
SET /p psw=

set label==finish
IF %psw%==lol1 call start.bat %label%
pause >NUL

:INVALID
CLS
ECHO INAVLID LOGIN.....
PING -n 3 127.0.0.1 > NUL
ECHO Please try again...
PING -n 3 127.0.0.1 > NUL
GOTO USERID
:MAIN
ECHO Welcome Nemraiku...
PING -n 3 127.0.0.1 > NUL


the task is simple

start.bat in the first lines jumps over to login in db.bat after that u type in user id and password. and now the part im strugling with is coming.
after sucessfully typing the password it will call up start.bat again but this time not from the begining of the script. i want it to jump straight over to the labeled :finish. instead of going to :main.
but it keeps going to :main.

i just dont get it why it wont skip it and jump to the label i want xDDD

is there anyone here who understand what i mean and see a possiblie solution to this problem?

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

Re: make a batch1 call up an specifique line in batch2

#2 Post by Squashman » 25 Feb 2015 07:25

Well for starters I don't think you understand what you are trying to code.

When you use the First Batch file to call the 2nd batch file, the 2nd batch file should finish and return control to the 1st batch file. Don't call the 1st batch file from the 2nd and remove the GOTO :MAIN from the 1st batch file.

redhawk
Posts: 7
Joined: 17 Feb 2015 05:52

Re: make a batch1 call up an specifique line in batch2

#3 Post by redhawk » 25 Feb 2015 07:53

i know perfectly what i am coding.
the only thing is that im going to use it for something later on in the script im creating so atm the script is pointless but when the entire surroundingdss of the script is done, then it wont be so pointless anymore.
im just interested to get the function working before i continue the rest of the script.

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

Re: make a batch1 call up an specifique line in batch2

#4 Post by Squashman » 25 Feb 2015 07:56

Hard for someone to help code a function when they don't understand the purpose, logic or intent of the goal.

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

Re: make a batch1 call up an specifique line in batch2

#5 Post by Squashman » 25 Feb 2015 08:00

Try this.
Change this line in your 2nd batch file.

Code: Select all

IF %psw%==lol1 call start.bat "GOTO %label%"


At the TOP of start.bat just put this

Code: Select all

%~1

redhawk
Posts: 7
Joined: 17 Feb 2015 05:52

Re: make a batch1 call up an specifique line in batch2

#6 Post by redhawk » 25 Feb 2015 08:49

OMG SQUASH UR AN GENIOUS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

thanks a lot :D

redhawk
Posts: 7
Joined: 17 Feb 2015 05:52

Re: make a batch1 call up an specifique line in batch2

#7 Post by redhawk » 25 Feb 2015 08:59

what this script is going to be used for is:

since im bored at work. im just making a fun program that is password protected. but as it is quite easy to rightclick and click edit on bat files it is god damn easy to find the passwords.

so what im going to use this function for is basically make the script go back and forth between many batch files just to confuse the crap out of the guy that tries to find the pass.
so i will switch out all set comands to foreign words that got nothing with password to do..... just because im bored....

so basically:
either u get your password. or u can stay in the batch files and be confused as **censored** for hours . xDD good way to "encrypt" a batch file with making the code so tidious that nobody would bother to try to find it xDDDD

im going to use this for somethig useful for my sake later on :D

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

Re: make a batch1 call up an specifique line in batch2

#8 Post by Squashman » 25 Feb 2015 11:07

It is kind of a basic form of a MACRO.

If you really want to obfuscate the password, you could use some basic encryption like ROT13.

Post Reply