网络编程
位置:首页>> 网络编程>> Python编程>> 使用Windows批处理和WMI设置Python的环境变量方法

使用Windows批处理和WMI设置Python的环境变量方法

作者:mighty13  发布时间:2023-07-28 23:07:37 

标签:Windows,WMI,Python,环境变量

大概在Python2.7.xx以前,安装Python时环境变量是需要自己设的,所以自己做了一个批处理文件.bat来设置环境变量Path,通过WMI命令wmic来实现。


::检查path中有没有相关路径
echo %path%|findstr /i "c:\python27\scripts"&&(goto run)

::先添加,防止没有时修改出错
wmic ENVIRONMENT create name="path",VariableValue="c:\python27\scripts;%path%"
::再修改,防止已有时添加出错
wmic ENVIRONMENT where "name='path' and username='<system>'" set VariableValue="c:\python27\scripts;%path%"
::再即时应用
set "path=c:\python27\scripts;%path%"

:run

来源:https://blog.csdn.net/mighty13/article/details/78015038

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com