Jump to content

Recommended Posts

Posted

Hi Friends,

I have a requirement. In my development environment I start a batch file which opens a windows shell, setup some environment variables and before exiting opens up another shell with the environment set and default directory set.

I then type in the required command to actually start working. This command takes in 7-8 parameters to start a required process. So my requirement is how do I automate this, I do not want to type in the command every time (or do a copy-paste to start working)

You guys may say that put the command in the batch file and just execute once you are on your command prompt, but I do not want to do this. What I am really looking for is that I just click the mouse button, which starts a batch file and pass my command to the final shell opened by the batch file.

Hope I am clear in what I am looking for.

If anyone has a suggestion please let me know.

Thanks and Regards.


Posted (edited)
Hope I am clear in what I am looking for.

No you are not, unless you need a hypothetical help instead of practical one.

If you are not from CIA, NSA or the like, maybe you could disclose a couple of lines of your batch... :whistle:

However, you just execute the other batch file, invoking it with desired parameters, example:

:: This is batch #1 Batch_1.cmd

:: Do whatever I am supposed to do

:: do something else

:: Set the path to the other batch file (if NOT in the same directory of Batch #1)

Set Batch_2_path=C:\directory\Batches\Batch_2

:: Set parameters needed for Batch_2

:: ONLY needed if parameters are somewhat calculated before in batch

Set param1=some_parameter_1

Set param2=some_parameter_2

Set param3=some_parameter_3

Set param4=some_parameter_4

Set param5=some_parameter_5

Set param6=some_parameter_6

Set param7=some_parameter_7

Set param8=some_parameter_8

:: now invoke Batch #2 passing parameters to it

Batch_2_path\Batch_2.cmd %param1% %param2% %param3% %param4% %param5% %param6% %param7% %param8%

:: otherwise just put the parameters on invoking line

Batch_2_path\Batch_2.cmd some_parameter_1 some_parameter_2 some_parameter_3 some_parameter_4 some_parameter_5 some_parameter_6 some_parameter_7 some_parameter_8

:: END of Batch #1

:: This is batch #2 Batch_2.cmd

:: The parameters are batch variables:

:: %0 name of Batch #2 (Batch_2.cmd in this case)

:: %1 parameter #1

:: %2 parameter #2

:: and so on

:: If you want to recreate the same parameters

Set param1=%1

Set param2=%2

Set param3=%3

Set param4=%4

Set param5=%5

Set param6=%6

Set param7=%7

Set param8=%8

:: Do whatever I am supposed to do

:: do something else

:: END of Batch #2

Please note that in this case, Batch #1 will pass command to Batch #2, if you want to return to batch #1, you need to use the CALL statement:

http://www.robvanderwoude.com/call.html

as in

CALL Batch_2_path\Batch_2.cmd %param1% %param2% etc.

jaclaz

Edited by jaclaz

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...