Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading Registry Values

Status
Not open for further replies.

tmcneil

Technical User
Nov 17, 2000
294
US
Hi All,

I've read a couple of the threads regarding registry keys, but could use some assistance. I've created a reg. key that holds a console_id value. The console id would be a number that represents a certain workstation. So, I have to have a reg. key on every workstation (4 windows boxes and 15 red hat linux boxes) with their own unique console_id value. I have no idea if you can have a reg key on a red hat linux box, but I can find that out when I get to that point. I'm juts trying to figure out a quick and easy way to use vbscript on an asp page to read a reg. key value and then send it to an Oracle stored procedure.

Thanks,
Todd
 
I've come up with this so far.

Code:
dim wshell
set wshell = server.createobject("wscript.shell")

'if i display the registry value it appears
response.write(wshell.regread("HKEY_LOCAL_MACHINE\SOFTWARE\ARINC\AIM\PACIS\MBTA\DWS"))

However, I get this error when running it:
Code:
Error Type:
WshShell.RegRead (0x80070002)
Unable to open registry key "HKEY_LOCAL_MACHINE\SOFTWARE\ARINC\AIM\PACIS\MBTA\DWS" for reading.
/mbta/canmsgPg.asp, line 418

Any ideas what I am doing wrong?
 
This code creates an object required error on the Set StdOut = WScript.StdOut line:

Code:
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set StdOut = WScript.StdOut
 
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
                    strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\ARINC\AIM\PACIS\MBTA\DWS"
strValueName = "ConsoleId"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
StdOut.WriteLine "Current ConsoleId Value: " & strValue

Any ideas.
 
I don't think an ASP page has an instantiated WScript object.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi PHV,

Well, I kind of thought that since these vbscript examples I found on the internet would would work in asp. We use asp alot here on our pages. Do you suggest another way to tackle the problem?

Todd
 
we have got webpages at work which create WshShell objects and use the .run method. however we get pop up boxes etc, but it i think PHV is right and this is client side code which is executed,,perhaps that is what you need to do? i guess the ASP would be thinkin you wanted to read the regisrty key on the web server rather than the client even if you could get access to wshshell.

if you can wshshell to work in client or server side script then you would get the error message about unable to open registry value\key because the registry value or key doesnt exist

i find when using wshshell to read the registry you need to do the following

strTemp = ""
On Error Resume Next
strTemp = WshShell.RegRead("blaa")
If strTemp <> "" Then
'we have a value to show or do something with
....you action here
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top