当前位置:网站首页>Configure system environment variables through bat script
Configure system environment variables through bat script
2022-07-06 09:52:00 【vv1025】
adopt bat Script configuration system environment variables
@echo off
echo ---------------------------------------
set pan=%~d0
set filePath=%~p0
set filePath=%pan%%filePath%
echo current path: %filePath%
REM add to PATH environment variable : If it already exists, do not add
echo ---------------------------------------
SET add_path=
SET toAdd=%~dp0
SET MYPATHCOPY=%PATH%
call :search1
echo %add_path%
SET toAdd=C:\Program Files\Go\bin
SET MYPATHCOPY=%PATH%
call :search2
echo %add_path%
echo add the path: %add_path%
call set xx=%Path%;%add_path%
wmic ENVIRONMENT where "name='Path' and username='<system>'" set VariableValue="%xx%"
pause
REM TIMEOUT /T 10
REM Method 1
:search1
for /f "tokens=1* delims=;" %%a in ("%MYPATHCOPY%") do (
if "%toAdd%"=="%%a" (
goto :isFinded
)
set MYPATHCOPY=%%b
goto :search1
)
set add_path=%toAdd%;%add_path%
goto :EOF
REM Method 2
:search2
for /f "delims=; tokens=1,2*" %%p in ("%MYPATHCOPY%") do (
REM @echo %%~p
SET MYPATHCOPY=%%~q;%%~r
if "%toAdd%"=="%%p" (
REM echo %%p
goto :isFinded
)
goto :search2
)
set add_path=%toAdd%;%add_path%
goto :EOF
:isFinded
echo The path already exists: %toAdd%
goto :EOF
边栏推荐
- 【深度学习】语义分割:论文阅读:(2021-12)Mask2Former
- What are the models of data modeling
- 发生OOM了,你知道是什么原因吗,又该怎么解决呢?
- Yarn organizational structure
- Basic concepts of libuv
- 一大波開源小抄來襲
- 学习单片机对社会的帮助是很大的
- [Yu Yue education] reference materials of power electronics technology of Jiangxi University of science and technology
- CANoe不能自动识别串口号?那就封装个DLL让它必须行
- Use of activiti7 workflow
猜你喜欢
Nc17 longest palindrome substring
[CV] target detection: derivation of common terms and map evaluation indicators
Combined search /dfs solution - leetcode daily question - number of 1020 enclaves
软件负载均衡和硬件负载均衡的选择
大学想要选择学习自动化专业,可以看什么书去提前了解?
Segmentation sémantique de l'apprentissage profond - résumé du code source
MapReduce instance (VII): single table join
Several silly built-in functions about relative path / absolute path operation in CAPL script
MapReduce instance (V): secondary sorting
Counter attack of noodles: redis asked 52 questions in a series, with detailed pictures and pictures. Now the interview is stable
随机推荐
Hero League rotation map automatic rotation
面试突击62:group by 有哪些注意事项?
嵌入式開發中的防禦性C語言編程
Nc29 search in two-dimensional array
Design and implementation of film and television creation forum based on b/s (attached: source code paper SQL file project deployment tutorial)
【深度学习】语义分割-源代码汇总
Release of the sample chapter of "uncover the secrets of asp.net core 6 framework" [200 pages /5 chapters]
There are software load balancing and hardware load balancing. Which one to choose?
【深度学习】语义分割:论文阅读:(2021-12)Mask2Former
Programmation défensive en langage C dans le développement intégré
018. Valid palindromes
How can I take a shortcut to learn C language in college
Libuv thread
May brush question 01 - array
O & M, let go of monitoring - let go of yourself
Use of activiti7 workflow
Mapreduce实例(六):倒排索引
[NLP] bert4vec: a sentence vector generation tool based on pre training
Popularization of security knowledge - twelve moves to protect mobile phones from network attacks
听哥一句劝,按这套嵌入式的课程内容和课程体系去学习