Change the influence of one batch file when other one is running

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
uglyninja
Posts: 7
Joined: 18 May 2018 14:22

Change the influence of one batch file when other one is running

#1 Post by uglyninja » 25 Jun 2018 04:24

I have two batch files. One.bat, and two.bat.
One.bat:

Code: Select all

@echo off
set/p a="> "
echo %a%
pause
exit
:secretlabel
echo Secret
pause
exit
Right now (for example) one.bat is running, waiting for my input.

What i want to do is, when now i open two.bat, it will open secretlabel.

You say - you could do that easily by scanning if two.bat is running and then go to secretlabel

But.

The thing is, i don't wanna hardcode any stuff into one.bat. Which means - i wanna pretty much "hack" one.bat and make it go to :secretlabel which would otherwise be inaccessible.

I'm pretty sure it's not possible, but if it is possible, tell me how :)

jeb
Expert
Posts: 917
Joined: 30 Aug 2007 08:05
Location: Germany, Bochum

Re: Change the influence of one batch file when other one is running

#2 Post by jeb » 25 Jun 2018 07:13

two.bat

Code: Select all

@echo off
call :secretLabel
exit /b

:secretLabel
one.bat
Obviously 8) , this will start :secretLabel in one.bat

You don't need to start one.bat before

uglyninja
Posts: 7
Joined: 18 May 2018 14:22

Re: Change the influence of one batch file when other one is running

#3 Post by uglyninja » 26 Jun 2018 07:29

Yup, i know of that way.
But i want one.bat to be running, and then when i open two.bat it should do it.

No way?

pieh-ejdsch
Posts: 203
Joined: 04 Mar 2014 11:14
Location: germany

Re: Change the influence of one batch file when other one is running

#4 Post by pieh-ejdsch » 26 Jun 2018 14:14

Hello
To communicate from one to two you can use waitfor.
Otherwise open a writing handle from set /p into your one - in two test this writing handle also into one, if this doesn't success then goto yourLabel.
Phil

Post Reply