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

Reading local PC registry via VBscript in browser 1

Status
Not open for further replies.

WS

IS-IT--Management
Apr 5, 2000
2
AU
New to the world of VBscript, so I thought I'd start with something simple!!. I just require an HTML/ASP page to read a registry value on the local PC and to create an unique URL from it.
The Code I have below, does the read bit fine - EXCEPT it reads the server's registry!!

Any assistance would be much appreciated....
----------------------------------------------
<%
Dim WSHShell, RegKey, macid, macbit, myURL

Set WSHShell = CreateObject(&quot;WScript.Shell&quot;)

RegKey = &quot;HKEY_LOCAL_MACHINE\SOFTWARE\SYSTEMHOUND\&quot;

macid = WSHShell.RegRead(RegKey & &quot;machine_id&quot;)

macid = replace(replace(macid,&quot;{&quot;,&quot;&quot;),&quot;}&quot;,&quot;&quot;)

macbit = right(macid,2)

myURL = &quot; & macbit & &quot;/&quot; & macid & &quot;.htm&quot;
%>
 
not too sure whether you can use WMI from within a web page but, this wil read a remote registry

const HKEY_LOCAL_MACHINE = &H80000002
strComputer = &quot;.&quot;
Set StdOut = WScript.StdOut

Set oReg=GetObject(&quot;winmgmts:{impersonationLevel=impersonate}!\\&quot; &_
strComputer & &quot;\root\default:StdRegProv&quot;)

strKeyPath = &quot;SYSTEM\CurrentControlSet\Services\Eventlog\System&quot;
strValueName = &quot;Sources&quot;
oReg.GetMultiStringValue HKEY_LOCAL_MACHINE,strKeyPath,_
strValueName,arrValues

For Each strValue In arrValues
StdOut.WriteLine strValue
Next

What you will need to do is identify the name of the computer using the web page and put that into Strcomputer.

for more info on types of keys and values you can read, refer to

Technet scripting
Regards
Steve Friday
 
The reason you're getting the server values is because you used server-side script tags, <% %>. Thus the code is run at the server.

Change your tags to

<SCRIPT LANGUAGE=&quot;VBScript&quot;></SCRIPT>

and it will run client-side. However, most browsers don't allow this type of operation by default. You'll have to go into your browser and enable the option to Initialize and Script ActiveX Objects Not Marked As Safe. Jon Hawkins
 
Thanks Steve & Jon

Just to put you in the picture, the page I am generating will be used as an &quot;Active Desktop&quot; background. Clicking on the link will invoke a call to Systemhound to display that particular desktop's hardware/software specs. The URL is generated by a couple of pieces from the desktop's registry.

I have done the deed using Jon's reply, but obviously the unsafe ActiveX issue could be a tricky one (particularly for a global company). If I enable access for WScript.Shell I'm guessing any page which uses this call will then have free reign to do as it likes.

Any suggestions for limiting &quot;safety&quot; just to me and my page !?!?

thanks again
 
Hello WS,

Are you successful in doing this ?

I am trying to acheive the similar functionality.

Appreciate any help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top