1

Have used the below code in order to get a list of the software on my computer however I want to obtain a list of all software installed on each separate computer on my LAN.

I want to get a list of computers on the network, then select the computer I want to scan. Don't want all computers to be scanned at once.

Many thanks for any related help.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;

namespace Final_Year_Project
{
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void btn_GetSoftware_Click(object sender, EventArgs e)
    {
        string uninstallKey =        @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
        using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(uninstallKey))
        {
            foreach (string skName in rk.GetSubKeyNames())
            {
                using (RegistryKey sk = rk.OpenSubKey(skName))
                {
                    try
                    {
                        string[] row = {     sk.GetValue("DisplayName").ToString()};
                        var listViewItem = new ListViewItem(row);
                        lst_Software.Items.Add(listViewItem);
                    }

                    catch (Exception ex)
                    { }
                }
            }
            lbl_SoftwareReturned.Text += " (" +     lst_Software.Items.Count.ToString() + ")";
        }  
    }

    private void lst_Software_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
GavinB703
  • 11
  • 4
  • Side note about your exception handling: https://stackoverflow.com/questions/5812726/is-it-ever-okay-to-catch-an-exception-and-do-nothing and http://mikehadlow.blogspot.com/2009/08/first-rule-of-exception-handling-do-not.html – Lews Therin Jan 30 '16 at 20:22
  • Possible duplicate of [List all the softwares installed on Network Computers by IP address](http://stackoverflow.com/questions/24568130/list-all-the-softwares-installed-on-network-computers-by-ip-address) – Lews Therin Jan 30 '16 at 20:28

1 Answers1

0

To access the registry on a different machine, use RegistryKey.OpenRemoteBaseKey:

Ben
  • 34,935
  • 6
  • 74
  • 113
  • Im new to this so this question might be obvious. This is a home network, and the computers are not connected to a server. Will the function you mentioned above still work? Appreciate your help. Thanks – GavinB703 Jan 31 '16 at 22:14
  • You need to have an authenticated network connection, remote registry service has to be enabled on the remote machine, and you have to have it accessible by the firewall. A home network doesn't have any of those things by default. – Ben Feb 01 '16 at 08:54