Link to home
Start Free TrialLog in
Avatar of gogetsome
gogetsomeFlag for United States of America

asked on

Get Client Registry Info

Hello, I need to get a list of the applications that are installed on the clients machine. My code works in a console app but not in a browser.

Does anyone know a way to get this code to work with asp.net? Or is there a better way to get apps installed on a client and also other info such as machine name, proc, memory etc..

I'm attempting to convert a console app that I found to do this but it not getting anything. This is my code:
Imports Microsoft.Win32
Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        GetInstalled()
    End Sub
    Private Sub GetInstalled()
        Dim uninstallKey As String = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
        Using rk As RegistryKey = Registry.LocalMachine.OpenSubKey(uninstallKey)
            For Each skName As String In rk.GetSubKeyNames()
                Using sk As RegistryKey = rk.OpenSubKey(skName)
                    Label1.Text = (sk.GetValue("DisplayName"))
                End Using
            Next
        End Using
    End Sub
End Class
This console app works:
 
Imports Microsoft.Win32
Module Module1
 
    Sub Main()
        GetInstalled()
    End Sub
    Private Sub GetInstalled()
        Dim uninstallKey As String = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
        Using rk As RegistryKey = Registry.LocalMachine.OpenSubKey(uninstallKey)
            For Each skName As String In rk.GetSubKeyNames()
                Using sk As RegistryKey = rk.OpenSubKey(skName)
                    Console.WriteLine(sk.GetValue("DisplayName"))
                End Using
            Next
        End Using
        Console.ReadLine()
    End Sub
End Module

Open in new window

Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

the problem is that your web application won't have access to the registry on the client PC
Avatar of gogetsome

ASKER

mmm, I found another example which does work. I uploaded it to the server and called the page from a client and it worked. Could it be that it works as I am a domain administrator?
markup:
 
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default3.aspx.vb" Inherits="Default3" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="Button1" runat="server" Text="Button" />
        <br />
        <br />
        <asp:Label ID="Label1" runat="server"
            Text="Label"></asp:Label>
    </div>
    </form>
</body>
</html>
 
Code behind:
 
 
Imports Microsoft.Win32
Partial Class Default3
    Inherits System.Web.UI.Page
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        GetInstalled()
    End Sub
    Private Sub GetInstalled()
        Dim uninstallkey As String = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
        Dim rk As RegistryKey = Registry.LocalMachine.OpenSubKey(uninstallkey)
        Dim sk As RegistryKey
        Dim skname() = rk.GetSubKeyNames
        For counter As Integer = 0 To skname.Length - 1
            sk = rk.OpenSubKey(skname(counter))
            If sk.GetValue("DisplayName") <> "" Then
                Label1.Text &= sk.GetValue("DisplayName") & "<br>"
            End If
        Next
 
    End Sub
End Class

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of oobayly
oobayly
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I agree with oobayly.

The code behind runs on the server and return the content of the server registry.
Yes, you are correct.

If I install a windows app on the client and run the code I would get the client info? I suppose that would be the only way?