Hi!
I want to read out special keys in my registry with shell_exec('reg query ...');
But some keys arent available for PHP, although they exist. I've also tried shell_exec('cmd /c reg query ... '); or exec('reg query ...');, but they dont find some keys too. However, there are a lot of keys which can be found and read. But unfortunetly not all, and those keys I need cant be found.

$getkey = shell_exec("reg query HKCU\Software\Microsoft\Windows\CurrentVersion\Runonce 2>&1");
echo $getkey;

I can see this key in my Registry-Editor and if I execute exact the same command in my commandline I get the right output. So the key defenitly exists.
But if I try to execute the command via PHP with the code above, it gives me an error message:
(translated into english)
Error: The registry key or value could not be found.

As I said, if I execute just the same command manually in the commandline I get the right output (data in that path).

Another example:

$getkey = shell_exec("reg query HKCU");
echo $getkey;

Outputs:

! REG.EXE VERSION 3.0
HKEY_CURRENT_USER
HKEY_CURRENT_USER\AppEvents
HKEY_CURRENT_USER\Console
HKEY_CURRENT_USER\Control Panel
HKEY_CURRENT_USER\Environment
HKEY_CURRENT_USER\Identities
HKEY_CURRENT_USER\Keyboard Layout
HKEY_CURRENT_USER\Printers
HKEY_CURRENT_USER\Software
HKEY_CURRENT_USER\UNICODE Program Groups

But if I open my registry editor I can see that their are again some keys are missing (which cant be found if I try to read them, just as in my first example).
Output commandline with same command:

C:\Dokumente und Einstellungen\Reiners1>reg query HKCU

! REG.EXE VERSION 3.0
HKEY_CURRENT_USER
HKEY_CURRENT_USER\AppEvents
HKEY_CURRENT_USER\Console
HKEY_CURRENT_USER\Control Panel
HKEY_CURRENT_USER\Environment
HKEY_CURRENT_USER\EUDC
HKEY_CURRENT_USER\Everstrike Software
HKEY_CURRENT_USER\Identities
HKEY_CURRENT_USER\Keyboard Layout
HKEY_CURRENT_USER\Printers
HKEY_CURRENT_USER\Software
HKEY_CURRENT_USER\UNICODE Program Groups
HKEY_CURRENT_USER\Windows 3.1 Migration Status
HKEY_CURRENT_USER\SessionInformation
HKEY_CURRENT_USER\Volatile Environment

I am using Windows XP Professional SP2, Apache 1.3.33 and PHP 5.0.4 from WAMP (e-novative), if that matters.

Anyone an idea how to fix this problem ?
many many thanks for reading. 🙂
Reiners

    Write a Reply...