| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 | @echo offREMREM This Batch-Script helps managing User-Environment Variables. REM Initial version by Paul-Dieter Klumpp, 2013-02-16REMREM It will set environment variables according to some configuration files.REM The configuration files are simple. If you want to set the PATH variable,REM you create file called "PATH.env". In that file, each line specifies a path.REM It will search all .01env and .02env files in the current directory. REM The files with the extension .01env gets evaluated before the files withREM the extension .02env.REMREM Some historyREM 2013-10-18: pkl, checking if those 01env-files exist..REM 2013-08-05: pkl, now there is an order in evaluation of files.REM now, search all files with extension ".env" and get the filename without '.env'goto :main :addToPath	set TEMPPA=%TEMPPA%%*goto :eof:setEnvVarByFile	set ENVSET=%TEMP%\tmp%USER%_envset.bat	echo echo. > %ENVSET%	set FILES=%*	set TMPFLIST=%TEMP%\tmp%USER%_files	dir /b %FILES% > %TMPFLIST%		echo Evaluating the following environment files now:	type %TMPFLIST%		for /F %%f in (%TMPFLIST%) do (		@echo.		echo Now environment file: %%f		for /F "tokens=1 delims=." %%n in ("%%f") do (					echo Environment %%n currently: !%%n!			setx OLD_%%n "!%%n!"			set i=0			set TEMPPA=			for /f "tokens=*" %%a in (%%f) do (				set /A i+=1				REM echo "wat: %%a"				call :addToPath %%a				REM echo "wot: !TEMPPA! "			)			setx %%n "!TEMPPA!"			echo SET %%n=!TEMPPA!>> %ENVSET%			echo.			echo "!i! Eintraege gesetzt: %%n = !TEMPPA!"			echo.			echo.		)	)	call %ENVSET%		del %ENVSET%	del %TMPFLIST%goto :eof:mainSETLOCAL EnableDelayedExpansion REM http://stackoverflow.com/questions/659647/how-to-get-folder-path-from-file-path-with-cmdset WD="%~dp0"cd "!WD!"REM first .01env, then .02env ... useful, when 02env uses variables which have been set in 01env. This keeps the correct order.IF EXIST *.01env (	echo Found .01env-files. Evaluating them now...	call :setEnvVarByFile *.01env)IF EXIST *.02env (	echo Found .02env-files. Evaluating them now...	call :setEnvVarByFile *.02env)echo Shells neu starten, damit die nun neuen Einstellungen geladen und aktiv werden.echo.pauseENDLOCAL:eof
 |