在 Visual Studio 2017 安装程序中修改用户和系统变量 [英] Modify user and system variables in Visual Studio 2017 installer

查看:44
本文介绍了在 Visual Studio 2017 安装程序中修改用户和系统变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想追加我的程序的安装文件夹作为值到用户和系统变量的路径变量.

I want to append the installation folder of my program as value to the path variable of user and system variables.

我听从了 michaelmoo 的指示.https://stackoverflow.com/a/21390793/9678802

I followed michaelmoo's instruction. https://stackoverflow.com/a/21390793/9678802

问题是路径变量的现有值将被删除.

The problem is that the existing value of path variable will be removed.

推荐答案

题外话:添加到路径涉及一些安全风险,一些性能问题,并可能导致应用程序干扰 - 可能还有其他一些问题.一般情况下最好避免.这是部署专业人员避免的已知风险" - 如果他们能提供帮助的话.

Digression: Adding to the Path involves some security risks, some performance issues, and can cause application interference - and probably a few other things. It is best avoided in general. It is a "known risk" avoided by deployment professionals - if they can help it.

AppPaths 的概念 是(部分)替代更新 Path 环境变量.它允许您的应用程序从Start =>开始运行对话框,但它不起作用从命令行.

The concept of AppPaths is a (partial) alternative to updating the Path environment variable. It allows your application to be started from the Start => Run dialog, but it does not work from the command line.

在命令提示符下似乎不起作用.

警告:哎呀,这个答案确实很糟糕(向明显试图帮助他人的作者道歉).但是,不应以任何形式或形式遵循该程序!这太危险了,我看到人们以更少的钱被送出去.使用包部署消除整个开发团队的环境路径将导致戏剧性 - 你可以肯定.在这种情况下,警告确实需要如此强烈.我已经看到了这种情况,甚至是由经验丰富的专业人士制作的软件包.

Warning: Ouch, that answer is very bad indeed (with apologies to the author who clearly tried to help others). That procedure should not be followed in any shape or form though! It is so dangerous that I have seen people sent out the door for far less. Wiping out a whole developer teams' environment path with a package deployment will cause drama - that you can be sure of. The warning really needs to be that strong in this case. I have seen it happen, and even by packages made by experienced professionals.

内置支持:就我而言,上述线程"的正确答案是这个.Windows Installer 内置支持添加处理所有合并更新问题的环境变量 - 甚至还有回滚支持 - 含义如果软件包安装失败,您的环境变量将恢复到其原始状态.此内置功能是必须使用"的功能.

Built-In Support: As far as I am concerned, the correct answer from the above "thread" is this one. Windows Installer has built-in support for adding environment variable that takes care of all merging and update issues - and it even has rollback support - meaning your environment variable will be restored to its original state should the package installation fail. This built-in feature is a "must use" functionality.

部署工具:所以必须使用内置功能,但是工具不支持时怎么办?最好的选择是获得 真正的部署工具",尤其是在 Visual Studio 安装程序项目还有几个问题(注意:这不是推销产品,而是告诉人们会导致几乎所有情况下的实际问题 - 您选择什么产品取决于您 - 显然 - 但 VS Installer Project 并不是一个完整的解决方案.

Deployment Tool: So the built-in feature has to be used, but how when the tool does not support it? The best option is to get a "real deployment tool", especially since there are several further problems with the Visual Studio Installer Projects (Note: this is not pitching products, it is telling people about serious pitfalls that will cause real problems in almost all cases - what product you choose is up to you - obviously - but the VS Installer Project just isn't a complete solution).

WiX:使用 WiX 更新 Path 变量非常简单.以及 环境元素的文档.

Orca:虽然可以后处理"您编译的 MSI 并在 环境表,我建议您使用经过测试和旨在帮助的适当工具一般来说,你会成功.Environment 表中的逗号错误或星号错误,您会得到完全错误的行为.

Orca: Though it is possible to "post-process" your compiled MSI and create the required entry in the Environment table, I would recommend that you use a proper tool instead that has been tested and designed to help you succeed in general. A comma wrong or a star wrong in the Environment table and you get completely wrong behavior.

这篇关于在 Visual Studio 2017 安装程序中修改用户和系统变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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