Jump to content

Recommended Posts

Posted (edited)

HI :)

How can i Run a .cmd file that runs 2 other .cmd files step by step like this:

1.cmd -> starts -> 2.cmd -> waits till 2.cmd is finished -> starts -> 3.cmd -> waits till 3.cmd is finished -> exit 1.cmd

Edited by Outbreaker

Posted

Create the following 3 scripts and put them in C:\

1.cmd

@Echo off&Setlocal enableextensions
Set "Two=C:\2.cmd"& Set "Three=C:\3.cmd"
Echo: This is the calling script, %0&Echo:
Echo: When you press any key
Echo: control will be passed to another script, "%Two%".
Pause>Nul
Call %Two% %0
Echo:&Echo: You have returned to the calling script again&Echo:
Echo: When you press any key
Echo: control will be passed to another script. "%Three%".
Pause>Nul
Call %Three% %0
Echo:&Echo: You have returned to the calling script, %0, for the last time&Echo:
Echo: When you press any key
Echo: you will exit.
Pause>Nul

2.cmd

@Echo off&Setlocal enableextensions
Set "One=%*"
Echo:&Echo: This is a called script, "%0"&Echo:
Echo: When you press any key
Echo: control will be passed to the original script, %One%.
Pause>Nul

3.cmd

@Echo off&Setlocal enableextensions
Set "One=%*"
Echo:&Echo: This is another called script, "%0"&Echo:
Echo: When you press any key
Echo: control will be passed to the original script, %One%.
Pause>Nul

Run 1.cmd to find out how the Call command works.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...