473,320 Members | 1,802 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

VB.NET How to access remote registry users volatile

I'm trying to return from a webpage, the remote HKCU\Volatile\CLIENTNAME

Here's what I'm doing so far:

Get the Machine Name via DNS - this bit works great:
Expand|Select|Wrap|Line Numbers
  1.         Public Shared Function GetMachineName(ByVal sender As System.Web.UI.Control) As String
  2.             Dim host As System.Net.IPHostEntry = Nothing
  3.             Dim machinename As String = ""
  4.  
  5.             host = System.Net.Dns.GetHostEntry(sender.Page.Request.ServerVariables("REMOTE_ADDR"))
  6.             machinename = host.HostName
  7.  
  8.             Return UCase(machinename).Replace(".CELLNETIX.LOCAL", "")
  9.  
  10.         End Function
  11.  
Then using that information, attempt to access the registry and pull the value:

Expand|Select|Wrap|Line Numbers
  1.         Public Shared Function getClientName(Optional ByVal MachineName As String = "localhost") As String
  2.             Dim strReturn As String = ""
  3.  
  4.             strReturn = regValue(RegistryHive.CurrentUser, "Volatile Environment", "CLIENTNAME", MachineName)
  5.  
  6.  
  7.             Return strReturn
  8.  
Remote Registry Function
Expand|Select|Wrap|Line Numbers
  1.         Public Shared Function regValue(ByVal hive As RegistryHive, _
  2.                                         ByVal key As String, _
  3.                                         ByVal ValueName As String, _
  4.                                         Optional ByVal MachineName As String = "localhost", _
  5.                                         Optional ByRef ErrInfo As String = "") As String
  6.             Dim objParent As RegistryKey = Nothing
  7.             Dim objSubkey As RegistryKey = Nothing
  8.             Dim sAns As String = ""
  9.  
  10.             Select Case hive
  11.                 Case RegistryHive.ClassesRoot
  12.                     objParent = RegistryKey.OpenRemoteBaseKey(RegistryHive.ClassesRoot, MachineName)
  13.                 Case RegistryHive.CurrentConfig
  14.                     objParent = RegistryKey.OpenRemoteBaseKey(RegistryHive.CurrentConfig, MachineName)
  15.                 Case RegistryHive.CurrentUser
  16.                     objParent = RegistryKey.OpenRemoteBaseKey(RegistryHive.CurrentUser, MachineName)
  17.                 Case RegistryHive.DynData
  18.                     objParent = RegistryKey.OpenRemoteBaseKey(RegistryHive.DynData, MachineName)
  19.                 Case RegistryHive.LocalMachine
  20.                     objParent = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, MachineName)
  21.                 Case RegistryHive.PerformanceData
  22.                     objParent = RegistryKey.OpenRemoteBaseKey(RegistryHive.PerformanceData, MachineName)
  23.                 Case RegistryHive.Users
  24.                     objParent = RegistryKey.OpenRemoteBaseKey(RegistryHive.Users, MachineName)
  25.             End Select
  26.  
  27.             Try
  28.                 objSubkey = objParent.OpenSubKey(key)
  29.                 If Not IsNothing(objSubkey) Then
  30.                     sAns = (objSubkey.GetValue(ValueName)).ToString
  31.                 End If
  32.             Catch ex As Exception
  33.                 ErrInfo = ex.Message
  34.             Finally
  35.                 If ErrInfo = "" And sAns = "" Then
  36.                     ErrInfo = _
  37.                        "No value found for requested registry key"
  38.                 End If
  39.             End Try
  40.             Return sAns
  41.         End Function
So this works if I run it from the Hostmachine, but not if I run it from remote machines.
Feb 26 '10 #1
2 4009
And can you tell me what error(s) do you get while running it from a remote machine?
Mar 14 '10 #2
could be due to
Optional ByVal MachineName As String = "localhost", _

is a quick response, I haven't analyzed carefully the code
Jul 17 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Thomas Tsang | last post by:
I am using ASP + IIS + MS access, when running the following codes: set Conn=Server.CREATEOBJECT("ADODB.CONNECTION") conn.open "DRIVER={Microsoft Access Driver (*.mdb)}; " &...
0
by: chris | last post by:
Hi, I try to connect to Access with php with te code below. The database and table are ok. <?php include('../adodb/adodb.inc.php'); $db =& ADONewConnection('access'); $dsn =...
56
by: Raphi | last post by:
Hi, I've been using an Access application I wrote for an office with the front-end stored on all computers and the back-end on one of them serving as an Access file server. Now we're moving...
21
by: Kevin Swanson | last post by:
I'm attempting some remote registry manipulation via C#. I've written a test app to simply grab a specified key from a specified hive on a specified machine. The call to OpenSubKey is throwing...
3
by: Steve Montgomery | last post by:
Does anyone have a sample block of code they can share for checking a DWORD value on a remote network machine's registry? For example, to validate a patch deployment. MSDN has a great sample for...
3
by: Terry Olsen | last post by:
I have administrator access on 2 different domains on the network at my job. I wrote a program to query the registry key on remote PC's and return the results to an excel spreadsheet. However, the...
0
by: bazzer | last post by:
hey, i am using visual basic.net 2003 and have an ASP.NET webform application thats accessing a microsoft access 2003 database. i kept getting the following error when i tried to run it: ERROR ...
0
by: bazzer | last post by:
hey, im trying to access a microsoft access database from an ASP.NET web application in visual basic 2003.NET. i get the following error when i try running it: Server Error in...
1
by: UK1967 | last post by:
I wrote a ASP.NET application (Windows 2003 Enterprise Server, IIS, .NET Framework 1.1). This application use the Windows (AD) account and impersonation. Some functions in this application contact,...
3
by: JB | last post by:
I am trying to access a registry key on computer like so: key = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, computerName).OpenSubKey(Subkey); There are two keys I am trying to...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.