I want to check if an app is alredy installed through launch conditions.If yes i want to exit the installer,if no the installation should continue.Could anyone tell how to achive this in c# installer?.
我想检查是否通过启动条件安装了一个应用程序。如果是,我想退出安装程序,如果没有安装继续。有人可以告诉如何在c#installer中实现此目的吗?
Regards, Harsh Suman
此致,苛刻的苏曼
3 个解决方案
#1
8
I'm not sure on how to do this specifically with C#, but while using the Nullsoft Installer this is the approach I've seen used: before installing, check for a registry key that is created during the install.
我不确定如何使用C#专门执行此操作,但在使用Nullsoft Installer时,这是我见过的方法:在安装之前,检查安装期间创建的注册表项。
Uninstallers show up in the Add/Remove Programs control panel. The list of the uninstallers is stored under HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall. If the installer registers an uninstaller, the uninstaller's key is a good key for the installer to check for, because:
卸载程序显示在“添加/删除程序”控制面板中。卸载程序列表存储在HKLM \ Software \ Microsoft \ Windows \ CurrentVersion \ Uninstall下。如果安装程序注册了卸载程序,则卸载程序的密钥是安装程序检查的一个好密钥,因为:
-
Assuming the program is being installed for all users, the key tested for must be under HKey Local Machine (HKLM) not a key specific to the current user (HKey Current User). The uninstaller's key is under HKLM
假设正在为所有用户安装程序,则测试的密钥必须在HKey Local Machine(HKLM)下,而不是特定于当前用户(HKey当前用户)的密钥。卸载程序的密钥在HKLM下
-
Sometimes multiple versions of the same program need to be installed side-by-side. Uninstaller keys should be specific to each version, so rules can be added to check the installer's version number against installed versions.
有时需要并排安装同一程序的多个版本。卸载程序密钥应特定于每个版本,因此可以添加规则以根据已安装的版本检查安装程序的版本号。
There is a limitation with checking for registry keys to tell if a program is installed: if the program is deleted out of Program Files by hand (without using the uninstaller), reinstalling will fail. To avoid this problem, after finding the uninstaller registry key, the installer can check that the uninstaller program still exists. If it does, it's probably safe to assume the program is still installed.
检查注册表项是否已安装程序存在限制:如果程序是手动删除程序文件(不使用卸载程序),则重新安装将失败。为避免此问题,在找到卸载程序注册表项后,安装程序可以检查卸载程序是否仍然存在。如果是这样,假设程序仍然安装可能是安全的。
While playing with installers and conditional installation, it's worth keeping in mind that sometimes reinstalling is useful for cleaning up problems. It can be tedious to be forced to walk through a (troublesome) uninstall to be able to reinstall.
在使用安装程序和有条件安装时,值得记住的是,有时重新安装对清理问题很有用。*通过(麻烦)卸载来重新安装可能会很乏味。
See NSIS's page on Add/Remove Programs for more details on uninstall registry keys.
有关卸载注册表项的更多详细信息,请参阅NSIS的“添加/删除程序”页面。
#2
4
Put an entry in the registry on install. If, when the installer runs, the entry is there, then the program is already installed (or your user has hacked the registry to make the installer think it has been). If it's not, then you haven't installed it yet.
在安装时在注册表中输入一个条目。如果在安装程序运行时,该条目存在,那么该程序已经安装(或者您的用户已经入侵了注册表以使安装程序认为它已经存在)。如果不是,那么你还没有安装它。
#3
0
If you don't want to put anything in the registry (due to admin rights or anything like that), you can simply check to see if the folders or files you install are present. Yes, this assumes you install to the same folder every time, but it's an option.
如果您不想在注册表中放置任何内容(由于管理员权限或类似内容),您只需检查您安装的文件夹或文件是否存在。是的,这假设您每次都安装到同一个文件夹,但这是一个选项。
#1
8
I'm not sure on how to do this specifically with C#, but while using the Nullsoft Installer this is the approach I've seen used: before installing, check for a registry key that is created during the install.
我不确定如何使用C#专门执行此操作,但在使用Nullsoft Installer时,这是我见过的方法:在安装之前,检查安装期间创建的注册表项。
Uninstallers show up in the Add/Remove Programs control panel. The list of the uninstallers is stored under HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall. If the installer registers an uninstaller, the uninstaller's key is a good key for the installer to check for, because:
卸载程序显示在“添加/删除程序”控制面板中。卸载程序列表存储在HKLM \ Software \ Microsoft \ Windows \ CurrentVersion \ Uninstall下。如果安装程序注册了卸载程序,则卸载程序的密钥是安装程序检查的一个好密钥,因为:
-
Assuming the program is being installed for all users, the key tested for must be under HKey Local Machine (HKLM) not a key specific to the current user (HKey Current User). The uninstaller's key is under HKLM
假设正在为所有用户安装程序,则测试的密钥必须在HKey Local Machine(HKLM)下,而不是特定于当前用户(HKey当前用户)的密钥。卸载程序的密钥在HKLM下
-
Sometimes multiple versions of the same program need to be installed side-by-side. Uninstaller keys should be specific to each version, so rules can be added to check the installer's version number against installed versions.
有时需要并排安装同一程序的多个版本。卸载程序密钥应特定于每个版本,因此可以添加规则以根据已安装的版本检查安装程序的版本号。
There is a limitation with checking for registry keys to tell if a program is installed: if the program is deleted out of Program Files by hand (without using the uninstaller), reinstalling will fail. To avoid this problem, after finding the uninstaller registry key, the installer can check that the uninstaller program still exists. If it does, it's probably safe to assume the program is still installed.
检查注册表项是否已安装程序存在限制:如果程序是手动删除程序文件(不使用卸载程序),则重新安装将失败。为避免此问题,在找到卸载程序注册表项后,安装程序可以检查卸载程序是否仍然存在。如果是这样,假设程序仍然安装可能是安全的。
While playing with installers and conditional installation, it's worth keeping in mind that sometimes reinstalling is useful for cleaning up problems. It can be tedious to be forced to walk through a (troublesome) uninstall to be able to reinstall.
在使用安装程序和有条件安装时,值得记住的是,有时重新安装对清理问题很有用。*通过(麻烦)卸载来重新安装可能会很乏味。
See NSIS's page on Add/Remove Programs for more details on uninstall registry keys.
有关卸载注册表项的更多详细信息,请参阅NSIS的“添加/删除程序”页面。
#2
4
Put an entry in the registry on install. If, when the installer runs, the entry is there, then the program is already installed (or your user has hacked the registry to make the installer think it has been). If it's not, then you haven't installed it yet.
在安装时在注册表中输入一个条目。如果在安装程序运行时,该条目存在,那么该程序已经安装(或者您的用户已经入侵了注册表以使安装程序认为它已经存在)。如果不是,那么你还没有安装它。
#3
0
If you don't want to put anything in the registry (due to admin rights or anything like that), you can simply check to see if the folders or files you install are present. Yes, this assumes you install to the same folder every time, but it's an option.
如果您不想在注册表中放置任何内容(由于管理员权限或类似内容),您只需检查您安装的文件夹或文件是否存在。是的,这假设您每次都安装到同一个文件夹,但这是一个选项。