Skip to content

Instantly share code, notes, and snippets.

@xiuhy
Created August 21, 2017 12:41
Show Gist options
  • Save xiuhy/e2db155a8df2d16762ea70af72180a3d to your computer and use it in GitHub Desktop.
Save xiuhy/e2db155a8df2d16762ea70af72180a3d to your computer and use it in GitHub Desktop.
再windows系统下,统一批量设置java开发系统路径
@echo off
rem --- set java home and maven home,devenvdir 可以根据实际情况改动 ---
set devenvdir=S:\springToolSuite
wmic ENVIRONMENT where "name='JAVA_HOME'" delete
wmic ENVIRONMENT where "name='MVN_HOME'" delete
wmic ENVIRONMENT create name="JAVA_HOME",username="<system>",VariableValue="%devenvdir%\jdk"
wmic ENVIRONMENT create name="MVN_HOME",username="<system>",VariableValue="%devenvdir%\apache-maven-3.0.4"
rem --- set classpath and path ---
set cp=%ClassPath%
set jhd=%devenvdir%\jdk\lib\dt.jar
set jht=%devenvdir%\jdk\lib\tools.jar
set jhb=%devenvdir%\jdk\bin
set pt=%Path%
set mhb=%devenvdir%\apache-maven-3.0.4\bin
call set cp=%%cp:%jhd%;=%%
call set cp=%%cp:%jht%;=%%
call set cp=%%cp:%jhb%;=%%
call set cp=%%cp:%jhd%=%%
call set cp=%%cp:%jht%=%%
call set cp=%%cp:%jhb%=%%
call set pt=%%pt:%jhb%;=%%
call set pt=%%pt:%mhb%;=%%
call set pt=%%pt:%jhb%=%%
call set pt=%%pt:%mhb%=%%
wmic ENVIRONMENT where "name='ClassPath'and username='<system>'" set VariableValue="%jhd%;%jht%;%jhb%;%cp%"
wmic ENVIRONMENT where "name='Path' and username='<system>'" set VariableValue="%jhb%;%mhb%;%pt%"
@echo on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment