wordpress   发布时间:2022-04-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了追加环境变量到Path大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

1 @echo off 2 setlocal enabledelayedexpansion 3 4 ::使用方法: 5 :: "C:\WINDOWS" 6 :: "C:\jar" 7 SET x="C:\jar" 8 Call :InPath %x% 9 goto :eof 10 11 12 :InPath 13 SET LocalPathCopy=
 1 @echo off
 2 setlocal enabledelayedexpansion 
 3 
 4 ::使用方法
 5 :: "C:\WINDOWS"
 6 :: "C:\jar"
 7 SET x="C:\jar"
 8 Call :InPath %x%
 9 goto :eof
10 
11 
12 :InPath
13 SET LocalPathCopy=%PATH%
14 :: whether exist %x%
15 IF "%LocalPathCopy%" == "" GOTO OVER
16 GOTO WHILE
17 
18 :: iterate path variable and check if the first parameter of InPath exists
19 :WHILE
20 FOR /f "delims=;,tokens=1,*" %%I IN ("%LocalPathCopy%") DO (
21   set LocalPathCopy=%%J
22   ::echo "%%~I" == "%1" --------- "%LocalPathCopy%"
23   IF /I "%%~I" == %1 (
24     SET Result=1
25     SET x=%%~I
26     echo %x% exists
27     GOTO OVER
28   )
29   GOTO WHILE
30 )
31 
32 :: remove "
33 SET x=%x:"=%
34 
35 IF "!Result!" == "" (
36     echo "%x%" dont exists so we‘ll add it to path
37     :: you can use SETX command correctly if it exists 
38     :: because the max length of your environment variable cant be great than 1024
39     :: SETX PATH "%Path%;%x%"
40     SET "Path=%Path%;%x%"
41     echo !PATH!
42     GOTO OVER
43 )
44 
45 pause.
46 
47 :OVER
48 PAUSE & GOTO :EOF

大佬总结

以上是大佬教程为你收集整理的追加环境变量到Path全部内容,希望文章能够帮你解决追加环境变量到Path所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: