Tuesday, December 4, 2007

How to read your system registry

How to read your system registry

To read your system registry

To access the system register we can take advantage of the system stored procedure that come with MSSQL Server.

These are the codes that will allow such operation.

<% Option Explict %>
<%

Dim objConn

Set objConn = Server.CreateObject("ADODB.Connection")

objConn.ConnectionString = "DSN=pubs;UID=sa;PWD=;"

objConn.Open

'Must use the master database, where xp_regread exists...

objConn.Execute "USE MASTER"

Dim strSQL

strSQL = "xp_regread 'HKEY_LOCAL_MACHINE'," & _

"'SOFTWARE\Microsoft\MSSQLServer\Setup'," & _

"'SQLPath'"

Dim objRS

Set objRS = objConn.Execute(strSQL)

Response.Write "SQL Server installed at " & objRS("Data")

objRS.Close

Set objRS = Nothing

objConn.Close

Set objConn = Nothing

7%>

No comments: