Is there an equivalent source command in Windows CMD as in bash or tcsh? Is there an equivalent source command in Windows CMD as in bash or tcsh? windows windows

Is there an equivalent source command in Windows CMD as in bash or tcsh?


In the usual Windows command prompt (i.e. cmd.exe), just using call mybat.bat did what I wanted. I got all the environment variables it had set.


The dos shell will support .bat files containing just assignments to variables that, when executed, will create the variables in the current environment.

  c:> type EnvSetTest.bat  set TESTXYZ=XYZ  c:> .\EnvSetTest.bat  c:> set | find "TESTX"  TESTXYZ=XYZ  c:>

IHTH.


Following example will help you to solve your problem.

env.bat This file is for setting variables. Its contents are given blow.

set name="test3"

test.bat Our main batch file.

call env.batcall print.batpause

Now print.bat batch file to print variables. Its contents given below

echo %name%