简体   繁体   English

检查是否安装了软件,如果没有,请使用c#安装

[英]check software installed or not, if not then install using c#

I've finished my C# WPF application, but I have a little problem : 我已经完成了C#WPF应用程序,但是有一个小问题:

My WPF application must need Adobe flash and .net framework and few softwares to run properly. 我的WPF应用程序必须需要Adobe Flash和.net框架以及少量软件才能正常运行。
so this application have to install these softwares one by one automatically if not installed in client system instead of install by user self. 因此,如果未安装在客户端系统中,则此应用程序必须自动一个接一个地安装这些软件,而不是由用户自己安装。

i have idea about check using "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall" but dont know how to complete? 我对使用“ HKEY_LOCAL_MACHINE \\ SOFTWARE \\ Microsoft \\ Windows \\ CurrentVersion \\ Uninstall”进行检查有想法,但是不知道如何完成?

string uninstallKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
            RegistryKey rk = Registry.LocalMachine.OpenSubKey(uninstallKey);
            {
                foreach (string skName in rk.GetSubKeyNames())
                {
                    RegistryKey sk = rk.OpenSubKey(skName);
                    {
                        if (sk.GetValue("DisplayName") == "Adobe Flash Player ActiveX")
                        {
                            MessageBox.Show("Installed");

                           // how to run the software one by one here???????

                        }

                    }
                }
            }

any solution??? 任何解决方案???

Note : i am giving this application to user in pen drive so i placed all needed software setup in pen drive itself. 注意:我正在使用笔驱动器将此应用程序提供给用户,因此我将所有需要的软件设置都放在了笔驱动器本身中。

Creating your own installer for an application is a time consuming and error prone process which doesn't make sense to deal with, considering the multitude of installers that already exist. 考虑到已经存在大量的安装程序,为应用程序创建自己的安装程序是一个耗时且容易出错的过程,因此无济于事。

My personal recommendation would be to examine the Windows Installer XML Toolkit (WiX). 我个人的建议是检查Windows Installer XML工具包 (WiX)。 It is completely free, and allows you to build a completely customized installer/uninstaller with external packages, with integration directly in Visual Studio. 它是完全免费的,并允许您使用外部软件包构建完全自定义的安装程序/卸载程序,并直接在Visual Studio中进行集成。

Trying to do this by hand is not as simple as detecting a registry key; 尝试手动执行此操作并不像检测注册表项那么简单。 you must deal with out of date versions, file permissions, installation options, the possibility that the program may not exist on the system even though the registry key exists (just to name a few hurdles). 您必须处理过时的版本,文件许可权,安装选项,即使存在注册表项,程序也可能在系统上不存在的可能性(仅举几个困难)。 WiX will manage your program version and external dependencies by using the power of the Windows Installer Database Engine. WiX将使用Windows Installer数据库引擎的功能来管理您的程序版本和外部依赖项。

It's to late but got the answer and your question is also very helpfull to me so thank you :) 已经很晚了,但是得到了答案,您的问题对我也很有帮助,谢谢:)

var keyName = @"SOFTWARE\Microsoft\Silverlight";
            using (var regKey = Registry.LocalMachine.OpenSubKey(keyName))
            {
                var version = regKey.GetValue("Version");
                if (version + "" == "5.1.30514.0")
                {
                    MessageBox.Show("Installed");
                }
                else
                {
                    MessageBox.Show("Uninstalled");
                }
                var DisplayName = regKey.GetValue("DisplayName");
                lsitBox1.Items.Add(version);
                // lsitBox1.Items.Add(DisplayName);
            }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM