如何在VS2013安装程序安装程序项目中添加环境变量? [英] How do I add an Environment Variable in a VS2013 Setup Installer Project?

查看:710
本文介绍了如何在VS2013安装程序安装程序项目中添加环境变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在使用VS2013的Visual Studio安装程序项目扩展(非ISLE)。

我需要在安装期间添加一个环境变量,我可以'似乎找到了关于如何做到这一点的任何信息 - (我确信这与我缺乏google技能有关)



我倾向于必须创建一个自定义动作,但我不知道这将如何完成。



任何指针都将收到非常感谢。



祝你好运

Erik

Hi,
I am using the Visual Studio Installer Projects Extension for VS2013 (NOT ISLE).
I need to add an Environment variable during install and I can't seem to find any information on how to do this - (I'm sure it has got to do with my lack of googleing skills)

I'm leaning towards having to create a custom action, but I don't know how this would be done at all.

Any pointers would be received with great gratitude.

Best regards
Erik

推荐答案

引用:我确定它与我缺乏google技能有关

输入 https://www.google.com/search?q=add+an+Environment+variable+during+install [ ^ ]。


结论:

好的,我接下来的所有内容我得出结论我最好早点而不是晚点进入WIX。因为我还必须让安装程序在构建服务器上工作,而且我还有一些其他更复杂的安装程序,我也必须在构建服务器上工作,这似乎是一个合理的路径。



一些链接可以帮助任何人开始使用VSInstallerProject中的CustomAction

这里有两个链接我想我将用于为安装程序创建CustomAction - 我将使用vbs - 我对此知之甚少。



http://www.robvanderwoude.com/vbstech_data_environment.php [ ^ ]



https://www.simple-talk.com/dotnet/visual-studio/visual-studio-setup---projects - 和 - 自定义动作/ [ ^ ]



我还发现了一个代码项目文章,可能部分适用于基本信息。

如何将命令行参数传递给MSI安装程序自定义操作 [ ^ ]



如果一切顺利,我会尝试做一些小提示或初学者文章。
Conclusion:
OK, with all the stuff I then went through I ended up with the conclusion that I would be better off getting into WIX sooner rather than later. Since I've also had to get the installer working on a build server and I've got a few other installers that are more complex that I will also have to get working on the build server this seemed to be a reasonable route to take.

Some Links that will help anyone get started with CustomAction in VSInstallerProject
Here are two links I think I'll be using for creating the CustomAction for the installer - I'm going with vbs - of which I know little.

http://www.robvanderwoude.com/vbstech_data_environment.php[^]

https://www.simple-talk.com/dotnet/visual-studio/visual-studio-setup---projects-and-custom-actions/[^]

I also found a codeproject article that may be partly applicable for basic information.
How to Pass Command Line Arguments to MSI Installer Custom Actions[^]

If all goes well I'll try to make a little tip or beginners article.


好的,我花了一段时间才回到这一点。

我冒险进入 WiX 这是正确的决定有很多原因。

然后我经历了很多箍 - 我认为 - 创建一些自定义动作和各种东西来检查环境变量已经存在,价值是什么,并报告它是否是一个意外的价值 - 意识到改变它将/可能破坏其他一些程序。所以 - 最后我没有在安装程序中设置环境变量,而是在程序中设置它。

这很有效 - 从我的程序中生成的任何进程都将默认使用这些设置。

OK, It's taken me a while to get back to this.
I did venture into WiX and it was the right decision for many reasons.
I then went through a lot of hoops - I think - to create some custom actions and all sorts of stuff to check if the Environment Variable existed already, what the value was and report back if it was an unexpected value - realising that changing it will/may ruin some other programmes. SO - in the end I went with NOT setting the Environment Variable in the Installer but instead setting it in the programme.
This works well - any processes spawned from my program will use these settings by default.
Environment.SetEnvironmentVariable(environmentVariableName, environmentVariableValue, EnvironmentVariableTarget.Process);


这篇关于如何在VS2013安装程序安装程序项目中添加环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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