如何在Visual Studio部署项目中更新环境变量

时间:2021-11-18 22:44:02

I would like to append a path to the PATH environment variable in a Visual Studio 2005 deployment project. How does one do this?

我想在Visual Studio 2005部署项目中追加PATH环境变量的路径。怎么做到这一点?

3 个解决方案

#1


4  

Use the registry editor view in the setup project and create the path key in the appropriate place ie. HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment and create a string value called "Path" and enter this as your value: "[%Path];[TARGETDIR]"

使用安装项目中的注册表编辑器视图,并在适当的位置创建路径键,即。 HKEY_LOCAL_MACHINE \ System \ CurrentControlSet \ Control \ Session Manager \ Environment并创建一个名为“Path”的字符串值并输入此值作为您的值:“[%Path]; [TARGETDIR]”

[%Path] is a placeholder for the original string in the existing Path value.

[%Path]是现有Path值中原始字符串的占位符。

#2


4  

There are problems with the above mentioned approach of using the registry editor view and creating a key called PATH with value "[%Path];[TARGETDIR]". While the method works fine when installing the program, the default behavior during uninstall is to delete the entire PATH variable, not just the added [TARGETDIR]. I have not found a way to disable this behavior, although it seems like some conditional behavior might be possible.

上述方法使用注册表编辑器视图并创建名为PATH且值为“[%Path]; [TARGETDIR]”的键存在问题。虽然该方法在安装程序时工作正常,但卸载期间的默认行为是删除整个PATH变量,而不仅仅是添加的[TARGETDIR]。我还没有找到一种方法来禁用这种行为,虽然看起来似乎有些条件行为可能。

#3


2  

You need to add a row to the Environment Table of the MSI file to do this. You can find information on that table here, http://msdn.microsoft.com/en-us/library/aa368369(VS.85).aspx. You can use Orca to do this or automate the procedure with some VB Script. The platform SDK contains the VB script file, WiRunSQL.vbs that can you used to automate build actions for your program.

您需要在MSI文件的Environment Table中添加一行才能执行此操作。您可以在此处找到有关该表的信息,http://msdn.microsoft.com/en-us/library/aa368369(VS.85).aspx。您可以使用Orca执行此操作或使用某些VB脚本自动执行该过程。平台SDK包含VB脚本文件WiRunSQL.vbs,您可以使用它来自动化程序的构建操作。

#1


4  

Use the registry editor view in the setup project and create the path key in the appropriate place ie. HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment and create a string value called "Path" and enter this as your value: "[%Path];[TARGETDIR]"

使用安装项目中的注册表编辑器视图,并在适当的位置创建路径键,即。 HKEY_LOCAL_MACHINE \ System \ CurrentControlSet \ Control \ Session Manager \ Environment并创建一个名为“Path”的字符串值并输入此值作为您的值:“[%Path]; [TARGETDIR]”

[%Path] is a placeholder for the original string in the existing Path value.

[%Path]是现有Path值中原始字符串的占位符。

#2


4  

There are problems with the above mentioned approach of using the registry editor view and creating a key called PATH with value "[%Path];[TARGETDIR]". While the method works fine when installing the program, the default behavior during uninstall is to delete the entire PATH variable, not just the added [TARGETDIR]. I have not found a way to disable this behavior, although it seems like some conditional behavior might be possible.

上述方法使用注册表编辑器视图并创建名为PATH且值为“[%Path]; [TARGETDIR]”的键存在问题。虽然该方法在安装程序时工作正常,但卸载期间的默认行为是删除整个PATH变量,而不仅仅是添加的[TARGETDIR]。我还没有找到一种方法来禁用这种行为,虽然看起来似乎有些条件行为可能。

#3


2  

You need to add a row to the Environment Table of the MSI file to do this. You can find information on that table here, http://msdn.microsoft.com/en-us/library/aa368369(VS.85).aspx. You can use Orca to do this or automate the procedure with some VB Script. The platform SDK contains the VB script file, WiRunSQL.vbs that can you used to automate build actions for your program.

您需要在MSI文件的Environment Table中添加一行才能执行此操作。您可以在此处找到有关该表的信息,http://msdn.microsoft.com/en-us/library/aa368369(VS.85).aspx。您可以使用Orca执行此操作或使用某些VB脚本自动执行该过程。平台SDK包含VB脚本文件WiRunSQL.vbs,您可以使用它来自动化程序的构建操作。