Environment variable path rewrite script(环境变量path重写脚本)

朋友估计是装Android Studio把环境变量搞没了,找了个重写环境变量的shell脚本,这里记录一下,万一哪天自己手滑

I guessed that my friend installed Android Studio to get rid of the environment variables. I found a shell script that rewrites the environment variables. Record it here, In case I slip by myself someday

脚本

@echo off
REM 声明采用UTF-8编码
chcp 65001&cls

REM 备份当前环境变量
echo 当前环境变量:
echo %Path%

echo 永久设置Hadoop、scala、Java、 go、spark、zookeeper环境变量

SETX /M GO_ROOT "C:\Go"

SETX /M JAVA_HOME "C:\Program Files\Java\jdk1.8.0_191"

SETX /M HADOOP_HOME "C:\hadoop"

SETX /M SCALA_HOME "C:\scala-2.11.8"

SETX /M SPARK_HOME "C:\spark-2.2.1-bin-hadoop2.7"

SETX /M ZOOKEEPER_HOME "C:\zookeeper-3.4.14"

SETX /M Path "%Path%;%ZOOKEEPER_HOME%\bin;%SPARK_HOME%\bin;%SPARK_HOME%\jars;%SCALA_HOME%\bin;%HADOOP_HOME%\bin;%JAVA_HOME%\bin;%GO_ROOT%\bin"

echo 修改完成, 即将重启文档管理器explorer
pause

REM 重启explorer.exe使环境变量立即生效
taskkill /im explorer.exe /f
echo ================================================
echo 开始重启“explorer.exe”进程
start explorer.exe

pause

重命名为winSetPath.bat , 管理员身份启动
Rename to winSetPath.bat, start as administrator

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\

最后加上默认环境变量

问题解决

posted @ 2022-02-28 22:42  dotExp  阅读(58)  评论(0编辑  收藏  举报