1

Assuming 'paths' is a file containing all the paths I need to write to the environment variable CLASSPATH, appended in the right format. I essentially need Windows equivalent of

CLASSPATH=$(cat paths)

In accordance with this answer I tried doing the below:

for /f "delims=" %A in ('cat paths.txt') do @set CLASSPATH=%A

(paths.txt has all the paths in the right format) but it does not work. Echoing '%CLASSPATH%' still gives me nothing. What am I doing wrong?

Community
  • 1
  • 1
Core_Dumped
  • 4,577
  • 11
  • 47
  • 71

1 Answers1

0

This in a .bat file would produce p1;p2;p3;

@echo off
setlocal enabledelayedexpansion
set CLASSPATH=
for /f "delims=" %%A in (paths.txt) do set "CLASSPATH=!CLASSPATH!%%A;"
echo %CLASSPATH%

rem to make it a permanent global
setx CLASSPATH %CLASSPATH%
Alex K.
  • 171,639
  • 30
  • 264
  • 288