Read/write registry key using .asp or .hta 
Author Message
 Read/write registry key using .asp or .hta

We are trying to Read a registry key/value using .asp
or .hta. The code below gives the following results, we
have tried using both as .asp page and .hta

Dim WshShell
Set WshShell = CreateObject("Wscript.Shell")

'Range is an existing value of TestKey and CAN BE READ
(TestKey has been inserted during installation of the
software)
strOrigVal = WshShell.RegRead
("HKEY_LOCAL_MACHINE\SOFTWARE\TestKey\Range")

'However, after using regedit to insert test under TestKey
and read with the following instruction:
strOrigVal2 = WshShell.RegRead
("HKEY_LOCAL_MACHINE\SOFTWARE\TestKey\test")

'we get the error message in IE:

'WshShell.RegRead error '80070002'
'Unable to open registry
key "HKEY_LOCAL_MACHINE\SOFTWARE\TestKey\test" for
reading.
'/Test.asp, line 21

Do you see any problems or possible explanation?
Any suggestions as an alternative approach?
Thanks much!



Mon, 04 Jul 2005 01:41:14 GMT  
 Read/write registry key using .asp or .hta


Quote:
> We are trying to Read a registry key/value using .asp
> or .hta. The code below gives the following results, we
> have tried using both as .asp page and .hta
<snip>
> Do you see any problems or possible explanation?
> Any suggestions as an alternative approach?
> Thanks much!

All ASP applications run with the Internet Guest user account, which doesn't
(and shouldn't, I think) have access to the system registry. I dunno if
there is a way to change this. If you need to store information like
settings etc. store them in a database or a text file, maybe.


Mon, 04 Jul 2005 09:00:37 GMT  
 Read/write registry key using .asp or .hta

Thanks for the clarification about ASP applications.
However, we're tyring to use an HTA aplication and having
trouble converting an ASP page than can read the registry
into an HTA page that does the same thing (the latter
requires the user to give permission). That is, he must
approve our authorizing the material he downloaded from
our site.

Thanks.

Quote:
>-----Original Message-----



>> We are trying to Read a registry key/value using .asp
>> or .hta. The code below gives the following results, we
>> have tried using both as .asp page and .hta
><snip>
>> Do you see any problems or possible explanation?
>> Any suggestions as an alternative approach?
>> Thanks much!

>All ASP applications run with the Internet Guest user

account, which doesn't
Quote:
>(and shouldn't, I think) have access to the system

registry. I dunno if
Quote:
>there is a way to change this. If you need to store
information like
>settings etc. store them in a database or a text file,
maybe.

>.



Tue, 05 Jul 2005 00:29:29 GMT  
 Read/write registry key using .asp or .hta

Quote:
> Dim WshShell
> Set WshShell = CreateObject("Wscript.Shell")

> 'Range is an existing value of TestKey and CAN BE READ
> (TestKey has been inserted during installation of the
> software)
> strOrigVal = WshShell.RegRead
> ("HKEY_LOCAL_MACHINE\SOFTWARE\TestKey\Range")

> 'However, after using regedit to insert test under TestKey
> and read with the following instruction:
> strOrigVal2 = WshShell.RegRead
> ("HKEY_LOCAL_MACHINE\SOFTWARE\TestKey\test")

> 'we get the error message in IE:

> 'WshShell.RegRead error '80070002'
> 'Unable to open registry
> key "HKEY_LOCAL_MACHINE\SOFTWARE\TestKey\test" for
> reading.
> '/Test.asp, line 21

> Do you see any problems or possible explanation?
> Any suggestions as an alternative approach?

Going from an ASP displayed in IE (with lowered security) with the above
client side script to an HTA version of the same ASP page will simply use
*less* restrictive security than IE.

In the context of reading a KEY (as opposed to reading a named value)
0x80070002 can mean the key doesn't exist (err.description starts with the
word 'Invalid') or the key exist but does not have a default value set
(err.description starts with the word 'Unable').

For a NAMED VALUE (as in your case), I've never seen 0x80070002 mean
anything other than the named value doesn't exist.  When I use regedit to
create a named value, it *never* displays 'value not set' the way a new key
does by default.  It appears that a named value always gets a default value
based on its type (string/dword/binary/etc.).

Since I can't see the registry on the actual client machine that you say
this occurs on, I can't confirm the the new 'test' named value really exists
as you say it does.

But if the client can read "HKEY_LOCAL_MACHINE\SOFTWARE\TestKey\Range", then
they can read "HKEY_LOCAL_MACHINE\SOFTWARE\TestKey\test" unless the registry
ACLs are weired out.

But (AFAIK) ACLs apply keys, not named valuse, so I don't see how reading a
named value 'Y' under key 'X' can succeed and reading named value 'Z' under
the same key 'X' can fail unless named value 'Z' doesn't really exist.

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US



Tue, 05 Jul 2005 11:52:58 GMT  
 Read/write registry key using .asp or .hta
I see you started a second thread on this subject, one that actually
provides better context.

How about we abandon this thread and keep the discussion on the newer
thread?

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US



Tue, 05 Jul 2005 12:33:51 GMT  
 Read/write registry key using .asp or .hta
Good idea!  Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Tue, 05 Jul 2005 23:35:32 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Reading registry keys in vbscript from ASP page

2. Reading/Writing to the Registry remotely using RegRead() and RegWrite()

3. using WSH to read and write registry

4. Read Registry Keys and Trees / API Call for Registry access

5. Class to Read/Write any Registry key

6. How to read/write a key to the registry

7. How to write and read registry keys

8. reading/writing to Registry from ASP via dll

9. Writing a VBS file which reads and writes to the registry

10. REGISTRY How can I read a registry key?

11. Reading registry from HTA

12. Writing to a registry key

 

 
Powered by phpBB® Forum Software