gogetsome
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\Window s\CurrentV ersion\Uni nstall"
Using rk As RegistryKey = Registry.LocalMachine.Open SubKey(uni nstallKey)
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
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\Window
Using rk As RegistryKey = Registry.LocalMachine.Open
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
the problem is that your web application won't have access to the registry on the client PC
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I agree with oobayly.
The code behind runs on the server and return the content of the server registry.
The code behind runs on the server and return the content of the server registry.
ASKER
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?
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?