title: How to update and query registry using batch file through php
body: <p>I am using batch file to add and query the windows registry as below:
  Below is to add the value in registry I name this as write.bat</p>
  
  <pre><code>%SystemRoot%\System32\reg.exe ADD "HKLM\SOFTWARE\SpecialAccounts\UserList" /f /v "MyCustomWorkgroupUsername" /t REG_DWORD /d 4
  </code></pre>
  
  <p>Below is to query the value in registry I name this as read.bat</p>
  
  <pre><code>for /f "tokens=3" %%a in ('%SystemRoot%\System32\reg.exe query "HKLM\SOFTWARE\SpecialAccounts\UserList" /v
   MyCustomWorkgroupUsername') do (set /a num = %%a )
  
   echo %num% &gt; "d:\\temp\\val.txt"
  </code></pre>
  
  <p>I am querying and writing the value in val.txt.</p>
  
  <p>Below is the php code:</p>
  
  <pre><code>&lt;?php
  $writeReg = "D:\\reg\\write.bat";
  $readReg = "D:\\reg\\read.bat";
  write_reg($writeReg);
  read_reg($readReg);
  function write_reg($writeReg)
  {
      system($writeReg);
      echo "Done";
  }
  function read_reg($readReg)
  {
      system($readReg);
      echo "Done";
  }
  
  ?&gt;
  </code></pre>
  
  <p>If I run just the batch file its working fine but when I run through php, I am unable to add the value. Please help me what is wrong here.</p>