当前位置:网站首页>通过bat脚本配置系统环境变量
通过bat脚本配置系统环境变量
2022-07-06 09:04:00 【vv1025】
通过bat脚本配置系统环境变量
@echo off
echo ---------------------------------------
set pan=%~d0
set filePath=%~p0
set filePath=%pan%%filePath%
echo current path: %filePath%
REM 添加PATH环境变量:如果已经存在则不添加
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 方法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 方法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
边栏推荐
- 单片机如何从上电复位执行到main函数?
- Mapreduce实例(八):Map端join
- Redis分布式锁实现Redisson 15问
- 手把手教您怎么编写第一个单片机程序
- 基于B/S的网上零食销售系统的设计与实现(附:源码 论文 Sql文件)
- Global and Chinese market of bank smart cards 2022-2028: Research Report on technology, participants, trends, market size and share
- In order to get an offer, "I believe that hard work will make great achievements
- 一大波開源小抄來襲
- Learning SCM is of great help to society
- A wave of open source notebooks is coming
猜你喜欢
What you have to know about network IO model
[deep learning] semantic segmentation - source code summary
Research and implementation of hospital management inpatient system based on b/s (attached: source code paper SQL file)
MapReduce instance (V): secondary sorting
Sqlmap installation tutorial and problem explanation under Windows Environment -- "sqlmap installation | CSDN creation punch in"
MapReduce instance (IV): natural sorting
Solve the problem of too many small files
MapReduce instance (VI): inverted index
学习单片机对社会的帮助是很大的
嵌入式开发比单片机要难很多?谈谈单片机和嵌入式开发设计经历
随机推荐
基于B/S的网上零食销售系统的设计与实现(附:源码 论文 Sql文件)
068.查找插入位置--二分查找
Redis distributed lock implementation redison 15 questions
Redis分布式锁实现Redisson 15问
英雄联盟轮播图手动轮播
小白带你重游Spark生态圈!
六月刷题01——数组
大学想要选择学习自动化专业,可以看什么书去提前了解?
一大波開源小抄來襲
A wave of open source notebooks is coming
Regular expressions are actually very simple
[Yu Yue education] reference materials of power electronics technology of Jiangxi University of science and technology
Webrtc blog reference:
May brush question 01 - array
[Yu Yue education] reference materials of complex variable function and integral transformation of Shenyang University of Technology
单片机实现模块化编程:思维+实例+系统教程(实用程度令人发指)
Mapreduce实例(八):Map端join
《ASP.NET Core 6框架揭秘》样章发布[200页/5章]
Global and Chinese markets for small seed seeders 2022-2028: Research Report on technology, participants, trends, market size and share
五月刷题26——并查集