![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
|
We are trying to get the registry key below on both the client machine and the server machine. Is there a VB function to get this or is there any code someone could help me with to get this information. HKEY_LOCAL_MACHINE\Software\Microsoft\DataAccess\F ullInstallVer Thanks in advance |
#4
| |||
| |||
|
|
I have a couple of bits of VBScript which will do what you want. I pulled both samples together below. I have not used the server based one against Win2003 so I don't know if it will work in that environment, but it used to work against Win2K or WinNT '======================================== '\\ Local machine example wscript.echo GetLocalRegistryValue("HKLM\SOFTWARE\Microsoft\Dat aAccess \FullInstallVer") '\\ Server Example 'wscript.echo GetRemoteRegistryValue("DARREN01","SOFTWARE\Micros oft \DataAccess","FullInstallVer") '\\--------------------------------------------------------------------- ---------- '\\ Name : GetRemoteRegistryValue '\\ Author : Darren Gosbell '\\ Date : 22 April 2002 '\\ Description: Returns a value from a remote machines registry '\\ Inputs : sMachine, sSubKeyName, sValueName '\\ Output : a string registry value '\\--------------------------------------------------------------------- ---------- Function GetRemoteRegistryValue(sMachine,sSubKeyName,sValue Name) Dim sValue Dim intResult Dim ObjWMIRegistry On Error Resume Next Set objWMIRegistry = GetObject("winmgmts:\\" & sMachine & "\root \Default:StdRegProv") If Err.Number <> 0 then WScript.Echo "Error: could not find host \\" & sMachine WScript.Quit(1) End If intResult = objWMIRegistry.GetStringValue(HKEY_LOCAL_MACHINE, sSubKeyName, _ sValueName , sValue) If intResult <> 0 Then WScript.Echo "Error: Can not get " & sValueName & " for " & sSubKeyName WScript.Echo "Note! This script is written to be used only with Windows NT or Windows 2000" WScript.Quit(1) End If If Err.Number <> 0 Then wscript.echo wscript.scriptname & ": Function GetRemoteRegistryValue(" & sMachine & ", " & sSubKeyValue & ", " & sValueName & ")" WScript.Echo "Error number: " & Err.Number WScript.Echo "Error description: " & Err.Description Wscript.Quit(1) End If If intResult = 0 Then GetRemoteRegistryValue = sValue End If End Function Function GetLocalRegistryValue(sRegValue) Set oShell = CreateObject("WScript.Shell") On Error Resume Next GetLocalRegistryValue = oShell.RegRead(sRegValue) ' If the value does not exist, error is raised If Err Then GetLocalRegistryValue = "" Err.clear End If ' If a value is present but uninitialized the RegRead method ' returns the input value in Win2k. If VarType(GetLocalRegistryValue) < vbArray Then If GetLocalRegistryValue = sRegValue Then GetLocalRegistryValue = "" End If End If On Error Goto 0 End Function '======================================== -- Regards Darren Gosbell [MCSD] dgosbell_at_yahoo_dot_com Blog: http://www.geekswithblogs.net/darrengosbell |
![]() |
| Thread Tools | |
| Display Modes | |
| |