升级应用程序时安装到相同的路径 [英] Install to same path when upgrading application

查看:278
本文介绍了升级应用程序时安装到相同的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在那里我实现自动更新的应用程序。我有一个程序检查,如果需要升级下载并运行新的安装程序(Visual Studio 2005的安装项目),之后程序重新推出的Web服务。一切都很好。

I have an application where I'm implementing automatic updates. I have a web service that the program checks and if it needs to upgrade it downloads and runs the new installer (Visual Studio 2005 Setup Project), after which the program relaunches. All well and good.

但如何确保在安装程序默认的相同的路径,用户最初安装程序安装路径?

But how do I make sure that the installation path in the installer defaults to the same path that the user originally installed the program to?

例如,如果用户从程序文件改成了C:\ SomeFolder,我将如何让安装程序检测到,并改变它的安装路径为C:的\ SomeFolder而不是程序文件?或者,如果用户选择安装它的当前用户,而不是所有用户?

For example, if the user changed it from program files to C:\SomeFolder, how would I make the installer detect that and change it's install path to C:\SomeFolder instead of program files? Or if the user chose to install it for "Current User" instead of "All Users"?

推荐答案

- 右单击安装项目
- 查看
-Registry
- 在左侧,展开HKEY_LOCAL_MACHINE和软件,然后单击制造商节点
- 在右侧,右键单击并添加字符串注册表项
-NAME注册表项INSTALLDIR
- 设置其值为 [TARGETDIR]

-Right click the Setup Project
-View
-Registry
-In the left side, expand the HKey_Local_Machine and Software and click the Manufacturer node
-In the right side, right click and Add String registry key
-Name the registry key InstallDir
-Set its value [TARGETDIR].

后,程序安装,你可以看到INSTALLDIR REGKEY包含位置。您更新的应用程序可以使用相同的路径。

一般只有我和大家之间的唯一区别是所创建的快捷方式的位置。您可以在安装期间运行的进程监视器,看看自己。

编辑:

更新应用程序可以使用安装目录的RegistryKey执行这些步骤。编号:如何:使用注册表启动条件来指定目标目录

The updater application can use the InstallDir RegistryKey with these steps. Ref: How to: Use a Registry Launch Condition to Specify a Target Directory

- 右单击更新程序的安装项目
- 查看
-Launch条件 - - 添加一个搜索的RegistryKey
- 指定的物业作为SEARCHFORINSTALLDIR
- 指定的REGKEY作为SOFTWARE \ ManufacturerName
-Leave根指向HKLM
- 指定的值作为INSTALLDIR

-Right click the Setup Project of your Updater
-View
-Launch Conditions
-Add a Search For RegistryKey
-Specify the Property as SEARCHFORINSTALLDIR
-Specify the RegKey as SOFTWARE\ManufacturerName
-Leave root pointing to HKLM
-Specify the Value as InstallDir

- 添加一个启动条件
- 指定的条件为SEARCHFORINSTALLDIR
-Leave InstallUrl和消息

-Add a Launch Condition
-Specify the condition as SEARCHFORINSTALLDIR
-Leave InstallUrl and Message

- 右单击安装项目
- 查看
- 文件系统
- 选择应用程序文件夹
- preSS F4来查看的应用程序文件夹
属性 - 指定的DefaultLocation为[SEARCHFORINSTALLDIR]

-Right click the Setup Project
-View
-File System
-Select Application Folder
-Press F4 to view the properties of the Application Folder
-Specify the DefaultLocation as [SEARCHFORINSTALLDIR]

现在,当您生成安装包更新程序并运行它,它会给你的价值在INSTALLDIR REGKEY的安装路径。

Now when you Build the Setup package for the Updater and run it, it will give you the value in the InstallDir regkey for the install path.

如果您希望禁用文件夹文本框和浏览按钮来更改这些更新程序prevent用户的安装路径,你可以使用<一个href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa370557%28v=vs.85%29.aspx">Orca.exe.逆戟鲸是一个数据库表编辑器用于创建和编辑Windows Installer程序包和合并模块。然后,只需按照这个安装项目,固定安装套件的位置

If you wish to disable the "Folder Textbox" and the "Browse" button to prevent users from changing the updaters install path you can use Orca.exe. Orca is a database table editor for creating and editing Windows Installer packages and merge modules. Then simply follow this setup project, fixing the location of installed kit

另一种方式,你可以做到这一点是继亚伦Stebner的网络如何修改默认基于注册表值一个基于MSI安装程序安装路径

Another way you could do this is following Aaron Stebner's How to modify the default install path in an MSI-based setup based on a registry value

这篇关于升级应用程序时安装到相同的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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