使用NSIS更新%PATH%环境变量 [英] Update %PATH% environment variable using NSIS
问题描述
我读到超过$ {NSIS_MAX_STRLEN} (1024)的字符串将被截断/损坏."
I read that "Strings longer than ${NSIS_MAX_STRLEN} (1024) will get truncated/corrupted."
如何安全更新%PATH%环境变量?
推荐答案
您可以从特殊构建页面,例如构建大字符串,它定义了NSIS_MAX_STRLEN=8192
并应防止您破坏主机路径.
You can use an alternative NSIS build from the special builds page like the large strings build that defines NSIS_MAX_STRLEN=8192
and should prevent you from breaking the host path.
在实践中,在一台台式计算机上,1024字节似乎足够了,但是在安装了许多工具的开发主机上(例如我的),该路径在操作后可能会中断,而8192字节的字符串构建从未扰乱我的计算机.
In practice, on a desktop machine, 1024 byte seems enough, but on a development host with many tools installed (like mine), the path might be broken after manipulation, while the 8192 bytes strings build had never perturbed my machine.
非常肯定的是,您可以在操作之前添加对路径长度的检查,并在尝试操作之前将路径接近NSIS_MAX_STRLEN
常量的情况下中止安装程序并显示一条消息.
To be very sure, you can add a check on the path length before manipulation and abort the installer with a message in the case where the path would be close to the NSIS_MAX_STRLEN
constant before trying to manipulate it.
这篇关于使用NSIS更新%PATH%环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!