:: An example showing how to pass values :: from one batch file to another :: In practice function.cmd could be a very complex script :: with lots of variables. :: The only variables that are visible to the main batch file :: are those returned in the last line of function.cmd :: Using SETLOCAL and ENDLOCAL means you don't have to worry about :: accidentally using the same variable name in both scripts. :: Thus removing a common source of bugs. ::--------------------start main.cmd-------------------:: @echo off SETLOCAL SET _first_bit=This text won`t change CALL function 10 first echo %_description% - %_number% CALL function 15 second echo %_description% - %_number% CALL function 25 third echo %_description% - %_number% CALL function 48 fourth echo %_description% - %_number% echo Original Variable-- %_first_bit% ::---------------------end main.cmd--------------------:: ::--------------------start function.cmd-------------------:: @echo off SETLOCAL :: Some random math with %1 SET /a _first_bit=%1 + 25 SET /a _second_bit=%_first_bit% - 10 SET /a _num=%_second_bit% + 100 :: Store %2 SET _descr=[%2] :: Now the important bit - returning the values... ENDLOCAL& SET _number=%_num%&SET _description=%_descr% ::---------------------end function.cmd--------------------::