Professional Web Applications Themes

How to read the windows registry? - PHP Development

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 [url]www.easyavatar.com[/url]...

  1. #1

    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 [url]www.easyavatar.com[/url]


    Norman Peelman Guest

  2. #2

    Default Re: How to read the windows registry?

    Just a correction to the code/error...

    --
    Avatar hosting at [url]www.easyavatar.com[/url]
    "Norman Peelman" <npeelmancfl.rr.com> wrote in message
    news:yRgdd.10645$1f.7009tornado.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 [url]www.easyavatar.com[/url]
    >
    >

    Norman Peelman Guest

  3. #3

    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
    --
    Alvaro G Vicario Guest

  4. #4

    Default Re: How to read the windows registry?

    "Alvaro G Vicario" <alvaro_QUITAR_REMOVEtelecomputeronline.com> wrote in
    message news:8gc4t4cu2blx$.kp0h3fsf6qx5.dlg40tude.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 [url]www.easyavatar.com[/url]


    Norman Peelman Guest

  5. #5

    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
    --
    Alvaro G Vicario Guest

  6. #6

    Default Re: How to read the windows registry?

    "Alvaro G Vicario" <alvaro_QUITAR_REMOVEtelecomputeronline.com> wrote in
    message news:cveaysjopzro$.1fufrnwqvix1i$.dlg40tude.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 [url]www.easyavatar.com[/url]


    Norman Peelman Guest

Similar Threads

  1. Cannot write to Windows Registry (VB .NET)
    By Nikolay Petrov in forum ASP.NET Security
    Replies: 1
    Last Post: July 15th, 02:52 AM
  2. Can't read/write to Registry
    By Nikolay Petrov in forum ASP.NET Web Services
    Replies: 10
    Last Post: December 3rd, 10:14 PM
  3. Windows XP registry hacks
    By Robert Moir in forum Windows Setup, Administration & Security
    Replies: 0
    Last Post: July 12th, 06:03 PM
  4. Windows XP Registry Security
    By Lindsay Gillam in forum Windows Setup, Administration & Security
    Replies: 2
    Last Post: July 11th, 05:29 PM
  5. Auditing Windows XP Registry
    By Bruno in forum Windows Setup, Administration & Security
    Replies: 1
    Last Post: July 4th, 08:38 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139