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

查看:29
本文介绍了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.以前从未这样做过,因此感谢任何提示.

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.

推荐答案

如果您希望永久更改/更新环境变量中的 PATH,可以使用 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天全站免登陆