dbTalk Databases Forums  

Registry Key

microsoft.public.sqlserver.olap microsoft.public.sqlserver.olap


Discuss Registry Key in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
jd
 
Posts: n/a

Default Registry Key - 10-06-2005 , 12:29 AM






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



Reply With Quote
  #2  
Old   
Darren Gosbell
 
Posts: n/a

Default Re: Registry Key - 10-06-2005 , 03:30 AM






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

Reply With Quote
  #3  
Old   
AshVsAOD
 
Posts: n/a

Default Re: Registry Key - 10-06-2005 , 06:24 PM



I would look at the admin templates of group policy. That is a much better
way to deploy mass registry edits.
"jd" <j@d.us> wrote

Quote:
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





Reply With Quote
  #4  
Old   
jd
 
Posts: n/a

Default Re: Registry Key - 10-06-2005 , 10:00 PM



Thanks all


"Darren Gosbell" <xxx (AT) xxx (DOT) com> wrote

Quote:
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



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.