script.bat可以对Windows PATH环境变量进行更改 [英] Can a script.bat make changes to Windows PATH Environment Variable

查看:267
本文介绍了script.bat可以对Windows PATH环境变量进行更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个脚本,当单击该脚本时,会将几个条目添加到Windows中的PATH环境变量中,而不是手动进行更改。我看到.bat文件由于各种原因在Windows上一直使用,所以.bat脚本可以帮助我这样的东西吗?

I'm trying to write a script that when clicked will add a couple of entries to the PATH Environment variable in Windows, instead of making the changes manually. I see .bat files being used all the time on Windows for a variety of reasons, so can a .bat script help me with something like that?

我实际上需要从Internet上的某个位置下载zip,将其解压缩到指定位置,然后更新环境变量中的PATH。如果你想在环境变量中永久更改/更新PATH,那么你从来没有这样做过任何提示。

I actually need to download a zip from a location on the Internet, extract it to a specified location, then update the PATH in environment variable. Never done this before so any hints appreciated.

推荐答案

可以使用SETX命令,例如

If you wish to change/update the PATH permanently in the environment variable, you can use the SETX command e.g.

setx path "%PATH%;C:\New Folder" 

有关访问系统文件夹的%PATH%和其他变量的更多详细信息,请参阅 http://vlaurie.com/computers2/Articles/environment.htm

For more details information on %PATH% and other variables to access to system folder, refer to http://vlaurie.com/computers2/Articles/environment.htm

这篇关于script.bat可以对Windows PATH环境变量进行更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆