How to write and read data from windows registry with php?

1

I need to write and read data in windows registry with php, how to do?

    
asked by anonymous 03.08.2017 / 18:40

1 answer

4

To write to the Windows registry, run the command reg import

<?php
exec('reg import c:\arquivo.reg');

To read a Windows registry, run the command reg export

<?php
// Exporta o registro para um arquivo texto
exec('reg export Hkey_local_Machine\Software\blabla C:\arquivo.reg');

// Em seguida, faz a leitura desse arquivo
$registro = file_get_contents('C:\arquivo.reg');

// Agora você trabalha com funções de manipulação de string para abstrair o que necessita da variável '$registro'.

The file "file.reg" will have something like this

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\leroLero]
"parametro1"=valor
"parametro2"=valor
"parametro3"=valor

Then you abstract what matters the parameters and their values.

* How to manipulate the string is another matter. You can ask a new question to avoid making the topic "too broad", which is a reason for closing.

Interesting topic (SO-en): link

    
03.08.2017 / 20:10