faqts : Computers : Programming : Languages : PHP : Common Problems : Tips and Tricks

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

12 of 15 people (80%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

Can I change NT registry settings from PHP / Apache?

Oct 7th, 2002 09:20
J Wynia, Nathan Wallace, Richard Lynch


Scary!

Okay, presumably you know what you're doing to edit the settings...

Assuming the user that Apache is logged in as is capable of executing
and editing whatever needs to be executed and edited, you could use
exec() to run command-line registry-editing programs...

--------------------------------
First, PHP can only access the registry on the server. That right there
stops this question about 50% of the time. PHP doesn't have access to
the client registry (and neither does regular Javascript).

However, if you want to use the registry for storing data from your
script (a legitimate use), you can directly access it through the
Windows Scripting Host COM object.

$shell = new COM("WScript.Shell") or die("This thing requires Windows
Scripting Host");
$registry_proxystring =
$shell->RegRead("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet
Settings\\ProxyServer") or die("I cannot find that key");

The above example opens the registry and grabs the value of the IE proxy
to a variable.

You can use $shell->RegWrite("keyname") to write to the registry.