Return to the 1st batch file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
falcios
Posts: 34
Joined: 02 Mar 2017 05:38

Return to the 1st batch file

#1 Post by falcios » 06 Jun 2021 18:36

1st batch file contains the call command

call "d:\sfd\dtsc\admt\bat\net use.bat"

Few lines from the 2nd batch file

:MENU
Echo Press 0 for Test
Echo Press 1 for Test1
Echo Press 2 for Test2
Echo Press 3 for Test3
Echo Press 4 for Test4
Echo Press 5 for EOF
Echo Press 6 for Exit
set /p input=Enter 1-6:

if %input% == 0 goto :Test
if %input% == 1 goto :Test1
if %input% == 2 goto :Test2
if %input% == 3 goto :Test3
if %input% == 4 goto :Test4
if %input% == 5 goto :EOF
if %input% == 6 goto :EXIT
:EOF
EOF
:EXIT
Exit /b

When I select :EOF it exits the 2nd batch file. Exit does also.

What command do I use in the second batch file to return to the 1st batch file?

Thanks in advance.

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

Re: Return to the 1st batch file

#2 Post by ShadowThief » 06 Jun 2021 18:47

A script run via call will return control to the script that called it once the second script is over.

That said, there's already a command called net use, so that may be causing issues. Never name a script the same thing as a command that already exists.

falcios
Posts: 34
Joined: 02 Mar 2017 05:38

Re: Return to the 1st batch file

#3 Post by falcios » 06 Jun 2021 19:36

Per your suggestion, I changed the second batch file to drivesmap.bat and it still doesn't return to the 1st script.

Any idea how to fix this?

Thanks

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

Re: Return to the 1st batch file

#4 Post by ShadowThief » 06 Jun 2021 19:46

No, because it should be doing that automatically. Post your entire scripts and we'll be able to troubleshoot more effectively.

falcios
Posts: 34
Joined: 02 Mar 2017 05:38

Re: Return to the 1st batch file

#5 Post by falcios » 06 Jun 2021 19:56

Thank you so much it worked.
As you suggested I have added a second call batch file in the original.

Post Reply