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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reads Registry Information

Status
Not open for further replies.

clear88

Programmer
Nov 29, 2001
24
CN
Hi there,

is there a way to read the registry database?

For example....

[ KEY ]
HKEY_LOCAL_MACHINE\Software\Microsoft\windows\CurrentVersion

[ Field ]
WallPaperDir

cheers
 
Hi Jon,

I read the doc and try it in my htm page below, however, the key/value can't be create/read! Any suggestions?

I am going to add the function to HTM page. So, when user access it, I can list user information there! :)

Cheers

--------------code-------------------
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=windows-1250&quot;>

<SCRIPT LANGUAGE=&quot;VBScript&quot;>
<!--

Dim WshShell, bKey
Set WshShell = WScript.CreateObject(&quot;WScript.Shell&quot;)

WshShell.RegWrite &quot;HKCU\Software\ACME\FortuneTeller\&quot;, 1, &quot;REG_BINARY&quot;
WshShell.RegWrite &quot;HKCU\Software\ACME\FortuneTeller\MindReader&quot;, &quot;Goocher!&quot;, &quot;REG_SZ&quot;

bKey = WshShell.RegRead(&quot;HKCU\Software\ACME\FortuneTeller\&quot;)
WScript.Echo WshShell.RegRead(&quot;HKCU\Software\ACME\FortuneTeller\MindReader&quot;)


-->
</SCRIPT>

</head>

<body bgcolor=&quot;#FFFFFF&quot; text=&quot;#000000&quot;>

</body>
</html>
 
Well, if the script is not being hosted in a .VBS or .WSF file, you'll need to change the following line of code:
Set WshShell = WScript.CreateObject(&quot;WScript.Shell&quot;)
to
Set WshShell = CreateObject(&quot;WScript.Shell&quot;)

and remove the following line:
WScript.Echo WshShell.RegRead(&quot;HKCU\Software\ACME\FortuneTeller\MindReader&quot;)

I believe you'll also need to add the RUNAT=SERVER attribute to your script tag.

FWIW, for this type of tracking, you may want to explore using a database, such as Access, ISO the registry.
Jon Hawkins
 
Hi Jon,

thanks for your help, the following code can create the key & value now. However, if I removed the line <<WScript.Echo WshShell.RegRead(&quot;HKCU\Software\ACME\FortuneTeller\MindReader&quot;)>>

how can I get the value [MindReader] and write it to the htm page??

cheers

-------------------------------code------------------------
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=windows-1250&quot;>

<SCRIPT LANGUAGE=&quot;VBScript&quot;>
<!--

Dim WshShell, bKey
Set WshShell = CreateObject(&quot;WScript.Shell&quot;)

WshShell.RegWrite &quot;HKCU\Software\ACME\FortuneTeller\&quot;, 1, &quot;REG_BINARY&quot;
WshShell.RegWrite &quot;HKCU\Software\ACME\FortuneTeller\MindReader&quot;, &quot;Goocher!&quot;, &quot;REG_SZ&quot;

bKey = WshShell.RegRead(&quot;HKCU\Software\ACME\FortuneTeller\&quot;)


-->
</SCRIPT>

</head>

<body bgcolor=&quot;#FFFFFF&quot; text=&quot;#000000&quot;>

</body>
</html>
------------------------------end-------------------------
 
The portion of code you must remove is the WScript.Echo because the script is not being hosted in Windows Scripting Host. The remaining portion of the code can be used to retrieve the value and then write it to your page, use a Msgbox, or whatever you choose. Jon Hawkins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top