当前位置:网站首页>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
边栏推荐
- MapReduce working mechanism
- Redis distributed lock implementation redison 15 questions
- Release of the sample chapter of "uncover the secrets of asp.net core 6 framework" [200 pages /5 chapters]
- Why is 51+ assembly in college SCM class? Why not come directly to STM32
- 嵌入式开发比单片机要难很多?谈谈单片机和嵌入式开发设计经历
- CAP理论
- 51单片机进修的一些感悟
- MapReduce instance (x): chainmapreduce
- Why can't TN-C use 2p circuit breaker?
- Lua script of redis
猜你喜欢

Interview shock 62: what are the precautions for group by?

51单片机进修的一些感悟

Summary of May training - from a Guang

DCDC power ripple test

I2C summary (single host and multi host)

Some thoughts on the study of 51 single chip microcomputer

CAPL 脚本打印函数 write ,writeEx ,writeLineEx ,writeToLog ,writeToLogEx ,writeDbgLevel 你真的分的清楚什么情况下用哪个吗?

Hugo blog graphical writing tool -- QT practice

C#/. Net phase VI 01C Foundation_ 01: running environment, process of creating new C program, strict case sensitivity, meaning of class library

Learning SCM is of great help to society
随机推荐
英雄联盟轮播图手动轮播
竞赛vscode配置指南
嵌入式开发比单片机要难很多?谈谈单片机和嵌入式开发设计经历
Solve the problem of too many small files
[deep learning] semantic segmentation - source code summary
Full stack development of quartz distributed timed task scheduling cluster
Research and implementation of hospital management inpatient system based on b/s (attached: source code paper SQL file)
Leetcode:608 树节点
Teach you how to write the first MCU program hand in hand
Nc29 search in two-dimensional array
Why can't TN-C use 2p circuit breaker?
Hero League rotation chart manual rotation
【深度学习】语义分割:论文阅读(NeurIPS 2021)MaskFormer: per-pixel classification is not all you need
One article read, DDD landing database design practice
Webrtc blog reference:
Scoped in webrtc_ refptr
Hero League rotation map automatic rotation
【深度学习】语义分割-源代码汇总
[deep learning] semantic segmentation: paper reading: (2021-12) mask2former
Defensive C language programming in embedded development