I am working on several batch files and I want them to share some variables, so I created a batch file with all these SetupEnv settings:
rem General setup :: To pause or not after running a batch file SET isPause = true :: The directory where your source code is located SET directory = D :: The folders where your primary & secondary source code is located :: I like to have two source code folders, if you don't then just have them pointing to the same folder SET primary_source_code = \Dev\App SET secondary_source_code = \Dev\App2 :::::::::::::::::::::::::::::::::::::::::::: XAMPP ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: rem If you're using XAMPP then set these up :: Your destination folder SET base_destination = C:\xampp\htdocs :: The base url that is pointing to your destination folder (in most cases it localhost) SET base_url = http://10.0.2.65 :::::::::::::::::::::::::::::::::::::::::: Angular ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: rem If you're using angular set these up :: The folder where you built code is copied SET build_file = dist
And from another batch file, I first call this file:
::setup call ../SetupEnv echo %directory% dir pause;
The problem is that even though the file runs smoothly, and I can see on the outputs that things are being configured, the variables do not get into the file from which I call it. Therefore, in this example, %directory% not printed.
EDIT I also tried using Joey's answer :
::setup for /f "delims=" %%x in (../SetupEnv.txt) do (set "%%x") echo %directory% dir pause
But that didn't work either, and %directory% did not print
batch-file
Naguib Ihab Sep 11 '17 at 2:33 on 2017-09-11 02:33
source share