当前位置:网站首页>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
- DCDC power ripple test
- Hero League rotation map automatic rotation
- MapReduce工作机制
- Research and implementation of hospital management inpatient system based on b/s (attached: source code paper SQL file)
- May brush question 27 - figure
- [Yu Yue education] reference materials of complex variable function and integral transformation of Shenyang University of Technology
- Which is the better prospect for mechanical engineer or Electrical Engineer?
- 018. Valid palindromes
猜你喜欢

Control the operation of the test module through the panel in canoe (Advanced)

Design and implementation of film and television creation forum based on b/s (attached: source code paper SQL file project deployment tutorial)

Can I learn PLC at the age of 33

大学想要选择学习自动化专业,可以看什么书去提前了解?

max-flow min-cut

零基础学习单片机切记这四点要求,少走弯路

tn-c为何不可用2p断路器?

Detailed explanation of cookies and sessions

Une grande vague d'attaques à la source ouverte

Regular expressions are actually very simple
随机推荐
MapReduce instance (VI): inverted index
May brush question 27 - figure
手把手教您怎么编写第一个单片机程序
Redis distributed lock implementation redison 15 questions
max-flow min-cut
068. Find the insertion position -- binary search
Detailed explanation of cookies and sessions
Hero League rotation chart manual rotation
068.查找插入位置--二分查找
五月集训总结——来自阿光
Full stack development of quartz distributed timed task scheduling cluster
[deep learning] semantic segmentation: thesis reading (neurips 2021) maskformer: per pixel classification is not all you need
One article read, DDD landing database design practice
Defensive C language programming in embedded development
Hard core! One configuration center for 8 classes!
数据建模有哪些模型
Elk project monitoring platform deployment + deployment of detailed use (II)
MapReduce instance (IV): natural sorting
Oom happened. Do you know the reason and how to solve it?
Day 5 of MySQL learning