January 12, 2011 at 11:05 am
Hi all,
Can any one help me out how to find instance name of sqlserver using registery query.
Thanks in advance.
January 12, 2011 at 11:22 am
Why not use a SQL Query?
select SERVERPROPERTY('MachineName')
select SERVERPROPERTY('InstanceName')
select SERVERPROPERTY('ServerName')
January 12, 2011 at 12:00 pm
Hi,
I want it through registery query.
January 12, 2011 at 1:19 pm
sravanthiyerramreddy86 (1/12/2011)
Hi,I want it through registery query.
Why?
January 12, 2011 at 2:45 pm
sravanthiyerramreddy86 (1/12/2011)
Hi all,Can any one help me out how to find instance name of sqlserver using registery query.
Thanks in advance.
Try modify this code (this visual basic script reads the SQL Server configuration from registry). Save as inventory.vbs and run from a command line as: cscript inventory.vbs>report.txt
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_CURRENT_USER = &H80000001
strServerName = "."
'Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!" & strServerName & "\root\default:StdRegProv")
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\root\default:StdRegProv")
strKeyPath = "HARDWARE\DESCRIPTION\System\CentralProcessor\"
objReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "0","ProcessorNameString",strProcNazov
'WScript.echo strProcNazov
For i=0 To 24
objReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & cstr(i),"ProcessorNameString",strPNazov
If IsNull(strPNazov) = 0 Then
i=i+1
Else
Exit For
End If
Next
strProcPocet = i
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion"
strValueName = "ProductName"
objReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strOSVersion
strKeyPath = "SOFTWARE\Microsoft\Microsoft SQL Server"
strValueName = "InstalledInstances"
objReg.GetMultiStringValue HKEY_LOCAL_MACHINE,strKeyPath, strValueName,arrValues
If IsNull(arrValues) = 0 Then 'It's a SQL Server! Enumerate it's instances
strMsg = strServerName & " is running the following SQL Instance(s): "
For Each strValue In arrValues
strKeyPath = "SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL"
strValueName = strValue
strSQLInstancia = strValue
objReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strVersion
strKeyPath = "SOFTWARE\Microsoft\Microsoft SQL Server\" & strVersion & "\Setup"
strValueName = "Edition"
objReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strSQLEdition
strValueName = "Version"
objReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strSQLVersion
strValueName = "ProductCode"
objReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strSQLProductCode
WScript.echo strSQLInstancia & "||" & strSQLEdition & "||" & strSQLVersion & "||" & strSQLProductCode & "||" & strProcNazov & "||" & strProcPocet & "||" & strOSVersion
Next
End If
Set objRegistry = Nothing
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply