简体   繁体   English

如何确定我的域计算机上是否安装了特定的应用程序

[英]How to determine whether a specific application is installed on my domain computers

How to determine whether a specific application is installed on my domain computers using C#? 如何确定是否使用C#在我的域计算机上安装了特定的应用程序?

Forgot to mention. 忘了提。 I have admin rights on the domain 我拥有该域的管理员权限

I cannot respond to peoples' questions... so I keep editing my post. 我无法回答人们的问题...所以我继续编辑自己的帖子。 .. The application is registered under Add/Remove in Control Panel ..该应用程序已在“控制面板”中的“添加/删除”下注册

Since your application is actually stored within your Control Panel, that means that it is generating a Registry Key. 因为您的应用程序实际上存储在控制面板中,所以这意味着它正在生成注册表项。 Since it generates a key for the msiexec utility. 由于它为msiexec实用程序生成密钥。 Your application information will be here: 您的申请信息将在这里:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall

What this means, is your Registry will contain information in the following categories: 这意味着您的注册表将包含以下类别的信息:

  • Display Name 显示名称
  • UninstallString 卸载字符串
  • Publisher 发行人

It includes a lot more, except those three will be the most viable. 它包括很多,除了那三个是最可行的。

  • Display Name: Should contain your products name. 显示名称:应包含您的产品名称。
  • UninstallString: This will contain your product GUID UninstallString:这将包含您的产品GUID
  • Publisher: Is the company name. 发布者:是公司名称。

So you can actually implement some basic Remoting, have a server force a user to run a .bat that will run your application, and etc. 因此,您实际上可以实现一些基本的远程处理,让服务器强制用户运行将运行您的应用程序的.bat等。

But one of the key values, is you can just do a simple loop within your Registry to determine if it is installed. 但是关键值之一是您可以在注册表中进行简单的循环以确定是否已安装。

Here is a tutorial . 这是一个教程

In order to iterate through you need to do something such as: 为了进行迭代,您需要执行以下操作:

// Registry 'MSIEXEC Guid'
public void RegistryFix()
{            
    // Create a Registry Instance.
    RegistryKey rKey = Registry.LocalMachine.OpenSubKey(@"\\SOFTWARE\\Microsoft
        \\Windows\\CurrentVersion\\Uninstall", true);

    // Loop Our Instance:
    foreach( string sub in rKey.GetSubKeyNames() )
    {

         #region Error Handling for 'Registry MSIEXEC'

         try
         {
             // Locate Boulevard Instance
             RegistryKey blvd = rKey.OpenSubKey(@"\\SOFTWARE\\Microsoft
                 \\Windows\\CurrentVersion\\Uninstall\\" + sub);

              // Specify Boulevard Display Name String
              string blvdDisplay = blvd.GetValue("DisplayName").ToString();

              // Search For:
              if (blvdDisplay.Contains("Boulevard"))
              {

                    // Now Obtain Uninstall String.
                    string blvdUninstall =   blvd.GetValue("UninstallString").ToString().Replace(@"/u", @"/f");

                     // Execute
                     Process u = Process.Start(blvdUninstall);
                     u.WaitForExit();

               }
           }
           #endregion

         // Unhandled / Null Error
         catch
        {                    
               // Write Exception:
               Console.WriteLine("Null Value Detected");
               throw new Exception("Invalid or Null Registry Value Detected.");
        } 
   }                         
}

So the above example is running a recursive loop and searching those Subkeys for the msiexec so it can initiate a repair. 因此,上面的示例正在运行递归循环,并在那些子项中搜索msiexec以便它可以启动修复。 So I didn't post all of the code for it to actually do that, but the point was to show you how to search those Registry Keys so you can choose what best fits your needs. 因此,我并没有发布所有代码来实际完成此操作,但重点是向您展示了如何搜索那些注册表项,以便您可以选择最适合自己的需求。

Now this is designed to run locally, so you may have to create an executable then create a logon.bat so once a user logs in it checks if it is installed and runs your application. 现在,它被设计为在本地运行,因此您可能必须创建一个可执行文件,然后创建一个logon.bat以便一旦用户登录它,便会检查它是否已安装并运行您的应用程序。

You can use Remoting, there are a lot of variations in order to run an application remotely. 您可以使用Remoting,为了远程运行应用程序,有很多变体。 You'll have to find what best suits you. 您必须找到最适合您的东西。 Hopefully this helps you. 希望这对您有帮助。

To explain a little bit about the above code fragment, in my implementation a local machine would start the application. 为了稍微解释一下上面的代码片段,在我的实现中,本地计算机将启动该应用程序。 It runs through a diagnoses phase to attempt to fix common errors encountered. 它贯穿诊断阶段,尝试修复遇到的常见错误。 The easiest way to calculate a large array of applications was to have ours linked to database which stores all the product Guids. 计算大量应用程序的最简单方法是将我们的应用程序链接到存储所有产品Guid的数据库。

So your request is very, very possible. 因此,您的请求非常有可能。 This should solve the question and point you where you need to go to actually implement it as well. 这应该可以解决问题,并指出您还需要实际实施该方法的地方。

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

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