Solve : Runnig 2 batch file?

Microsoft Microsoft DOS in Microsoft 3 years ago

  1   0   0   0   0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Hello All,
There is an example of what I am try to ACHIEVE

I Created a test1.bat file. Inside that batch file added
-----------
echo off
cls
START C:\test2.bat
-----------

Now I created  test2.bat and added it to test1.bat
-----------
echo off
cls

echo.test 2 here..
pause
-----------

When I execute I see the test2.bat open due to the pause command. What I was try to achieve is the test2.bat should close on its own even though you have a pause command.
When you complete the action I see the command prompt still running. I need to close it once the execution is done.
Hope if any one could help me.

Thanks & Regards
Girish Katti
The pause command will wait for a key to be pressed to continue. I do not know the technical reasons, but it will cause the command window not to terminate or continue on until a key has been pressed.

If the window remains open even after the script has completed, try adding CMD /c between start and test.bat .Hi,
Adding CMD /C closes the window after the second batch file is executed. Is there any way we can close the batch file having a pause entry.
I to agree its virtually not possible to do but any work around.
If you want it to stay open, replace cmd /c with cmd /k.Hi,
What I exactly need was to close the batch file having a pause statement.
Presently we are calling the second batch file from the first batch file and while we execute the first the second still remains open due to the pause statement.
I need the second batch file to close when we execute the first one.

Thanks in advance.


Quote from: girishkatti123 on June 21, 2009, 10:22:26 PM

I need the second batch file to close when we execute the first one.
Thanks in advance.
That just won't work. Pause waits for a key to be pressed. If you want to wait for a specific time, try this. Replace xx with desired time in seconds.

PING localhost -n xx -w 1000 > nulThanks for all your inputs.
I will use the ping command and then send a enter keyword to the batch file.

Posted on 21 May 2022, this text provides information on Microsoft related to Microsoft DOS in Microsoft. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Tuteehub forum answer Answers

Post Answer

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.