How to read the windows registry?

This is a discussion on How to read the windows registry? within the alt.comp.lang.php forums, part of the PHP Programming Forums category; I can successfully open the 'WScript.Shell' COM object but cannot seem to access the 'HKEY_CURRENT_CONFIG' root system. I am ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-19-2004
Norman Peelman
 
Posts: n/a
Default How to read the windows registry?

I can successfully open the 'WScript.Shell' COM object but cannot seem to
access the 'HKEY_CURRENT_CONFIG' root system. I am trying to read the
current screen resolution in width and height.

The error I get is 'Invoke() failed, Exception occurred'
Warning: (null)(): Invoke() failed: Exception occurred.
Source: WshShell.RegRead Description: Unable to open registry key
"HKEY_CURRENT_CONFIG\System\CurrentControlSet\Cont rol\VIDEO\" for reading.
in C:\php434\registry.php on line 8

code:
<?php

$reg = new COM("WScript.Shell") or die("Requires Windows Scripting Host");
$k =
"HKEY_CURRENT_CONFIG\\System\\CurrentControlSet\\C ontrol\\VIDEO\\8B6D7859-A6
39-4A15-8790-7161976D057A\\0000\\DefaultSettings.XResolution\\" ;

echo $k."\n\r";
$disp = $reg->RegRead($k);
echo '-'.$disp."-\n\r";

?>


Norm
--
Avatar hosting at www.easyavatar.com


Reply With Quote
  #2 (permalink)  
Old 10-20-2004
Norman Peelman
 
Posts: n/a
Default Re: How to read the windows registry?

Just a correction to the code/error...

--
Avatar hosting at www.easyavatar.com
"Norman Peelman" <npeelman@cfl.rr.com> wrote in message
news:yRgdd.10645$1f.7009@tornado.tampabay.rr.com.. .
> I can successfully open the 'WScript.Shell' COM object but cannot seem

to
> access the 'HKEY_CURRENT_CONFIG' root system. I am trying to read the
> current screen resolution in width and height.
>
> The error I get is 'Invoke() failed, Exception occurred'
> Warning: (null)(): Invoke() failed: Exception occurred.
> Source: WshShell.RegRead Description: Unable to open registry key
> "HKEY_CURRENT_CONFIG\System\CurrentControlSet\Cont rol\VIDEO\8B6D7859-A6
> 39-4A15-8790-7161976D057A\0000\\DefaultSettings.XResolution\" for reading.
> in C:\php434\registry.php on line 8
>
> code:
> <?php
>
> $reg = new COM("WScript.Shell") or die("Requires Windows Scripting Host");
> $k =
>

"HKEY_CURRENT_CONFIG\\System\\CurrentControlSet\\C ontrol\\VIDEO\\8B6D7859-A6
> 39-4A15-8790-7161976D057A\\0000\\DefaultSettings.XResolution\\" ;
>
> echo $k."\n\r";
> $disp = $reg->RegRead($k);
> echo '-'.$disp."-\n\r";
>
> ?>
>
>
> Norm
> --
> Avatar hosting at www.easyavatar.com
>
>



Reply With Quote
  #3 (permalink)  
Old 10-20-2004
Alvaro G Vicario
 
Posts: n/a
Default Re: How to read the windows registry?

*** Norman Peelman wrote/escribió (Tue, 19 Oct 2004 22:49:02 GMT):
> I can successfully open the 'WScript.Shell' COM object but cannot seem to
> access the 'HKEY_CURRENT_CONFIG' root system. I am trying to read the
> current screen resolution in width and height.


If the key does exist, I'd check whether the user the script is running as
has permission to read the key.

I suppose you're writing a shell script or something similar, aren't you?


--
-- Álvaro G. Vicario - Burgos, Spain
-- Thank you for not e-mailing me your questions
--
Reply With Quote
  #4 (permalink)  
Old 10-20-2004
Norman Peelman
 
Posts: n/a
Default Re: How to read the windows registry?

"Alvaro G Vicario" <alvaro_QUITAR_REMOVE@telecomputeronline.com> wrote in
message news:8gc4t4cu2blx$.kp0h3fsf6qx5.dlg@40tude.net...
> *** Norman Peelman wrote/escribió (Tue, 19 Oct 2004 22:49:02 GMT):
> > I can successfully open the 'WScript.Shell' COM object but cannot seem

to
> > access the 'HKEY_CURRENT_CONFIG' root system. I am trying to read the
> > current screen resolution in width and height.

>
> If the key does exist, I'd check whether the user the script is running as
> has permission to read the key.
>
> I suppose you're writing a shell script or something similar, aren't you?
>
>


Yes, I am writing shell scripts. I have started to think that maybe
permissions is the problem as I can read some keys and not others.

Thanks for the info.

Norm


---
Avatar hosting at www.easyavatar.com


Reply With Quote
  #5 (permalink)  
Old 10-20-2004
Alvaro G Vicario
 
Posts: n/a
Default Re: How to read the windows registry?

*** Norman Peelman wrote/escribió (Wed, 20 Oct 2004 10:08:06 GMT):
> Yes, I am writing shell scripts. I have started to think that maybe
> permissions is the problem as I can read some keys and not others.


Run regedit and check permissions right-clicking on the key.


--
-- Álvaro G. Vicario - Burgos, Spain
-- Thank you for not e-mailing me your questions
--
Reply With Quote
  #6 (permalink)  
Old 10-21-2004
Norman Peelman
 
Posts: n/a
Default Re: How to read the windows registry?

"Alvaro G Vicario" <alvaro_QUITAR_REMOVE@telecomputeronline.com> wrote in
message news:cveaysjopzro$.1fufrnwqvix1i$.dlg@40tude.net.. .
> *** Norman Peelman wrote/escribió (Wed, 20 Oct 2004 10:08:06 GMT):
> > Yes, I am writing shell scripts. I have started to think that maybe
> > permissions is the problem as I can read some keys and not others.

>
> Run regedit and check permissions right-clicking on the key.
>
>
> --
> -- Álvaro G. Vicario - Burgos, Spain
> -- Thank you for not e-mailing me your questions
> --


Got it... I did mess with the permissions a bit but I think the main
problem was not including {} around on of the key names... Thanks!

Norm


--
Avatar hosting at www.easyavatar.com


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 12:16 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0