title: PHP in WAMP can not access mapped drive
body: <p>Relative:</p>
  
  <p><a href="https://stackoverflow.com/questions/2592910/mapped-network-drives">Mapped Network Drives</a></p>
  
  <p><a href="https://stackoverflow.com/questions/2763271/service-not-able-to-access-a-mapped-drive">Service not able to access a mapped drive</a></p>
  
  <p><a href="https://stackoverflow.com/questions/11872803/php-is-dir-and-mkdir-not-working-on-mapped-network-drive">PHP is_dir and mkdir not working on mapped network drive</a></p>
  
  <p>I know this is very old-school, but I just can't figure it out...</p>
  
  <p>On a Windows 2003 with wamp (apache 2.2, PHP 5.3.10) run as a service. Following the above link, I've already made it run as <code>Administrator</code> instead of <code>SYSTEM</code>. But still no luck.</p>
  
  <p>I made a <code>.bat</code> file to make it clear:</p>
  
  <pre><code>@echo off
  whoami
  net use
  php -r "var_dump(scandir('Z:\\'));"
  php -r "var_dump(scandir('\\\\192.168.211.86\\voice'));"
  php -r "var_dump(scandir('//192.168.211.86/voice'));"
  </code></pre>
  
  <p>And if I run it in <code>cmd</code>, the result is:</p>
  
  <pre><code>serv2003\administrator
  New connections will be remembered.
  
  
  Status       Local     Remote                    Network
  -------------------------------------------------------------------------------
  OK           R:        \\192.168.211.86\voice    Microsoft Windows Network
  OK           Z:        \\192.168.211.86\voice    Microsoft Windows Network
  The command completed successfully.
  
  array(5) {
    [0]=&gt;
    string(1) "."
    [1]=&gt;
    string(2) ".."
    [2]=&gt;
    string(6) "Folder"
  }
  array(5) {
    [0]=&gt;
    string(1) "."
    [1]=&gt;
    string(2) ".."
    [2]=&gt;
    string(6) "Folder"
  }
  array(5) {
    [0]=&gt;
    string(1) "."
    [1]=&gt;
    string(2) ".."
    [2]=&gt;
    string(6) "Folder"
  }
  </code></pre>
  
  <p>But if I run it in Apache:</p>
  
  <pre><code>&lt;body&gt;&lt;pre&gt;
  &lt;?php
  echo `C:\path\to\test.bat`;
  ?&gt;
  &lt;/pre&gt;&lt;/body&gt;
  </code></pre>
  
  <p>it outputs:</p>
  
  <pre><code>serv2003\administrator
  New connections will be remembered.
  
  
  Status       Local     Remote                    Network
  -------------------------------------------------------------------------------
  Unavailable  Z:        \\192.168.211.86\voice    Microsoft Windows Network
  The command completed successfully.
  
  
  Warning: scandir(Z:\): failed to open dir: No such file or directory in Command line code on line 1
  
  Warning: scandir(): (errno 2): No such file or directory in Command line code on line 1
  bool(false)
  
  Warning: scandir(\\192.168.211.86\voice): failed to open dir: No such file or directory in Command line code on line 1
  
  Warning: scandir(): (errno 2): No such file or directory in Command line code on line 1
  bool(false)
  
  Warning: scandir(//192.168.211.86/voice): failed to open dir: No such file or directory in Command line code on line 1
  
  Warning: scandir(): (errno 2): No such file or directory in Command line code on line 1
  bool(false)
  </code></pre>
  
  <p>Notice that yes there's a <code>R:</code> driving missing in Apache module, but since I'm accessing <code>Z:</code>, I assume that's not the problem.</p>
  
  <p>I don't have access to the remote folder, and I can't copy all files to local system. All I need is the ability to read them in PHP. What can I do?</p>
  
  <p>Thanks in advance!</p>
  
  <p><strong>Edit 1</strong>:</p>
  
  <p>Not sure if this matters, but I'm accessing this server via Remote Desktop (it's geographically far from me).</p>
  
  <p>And the <code>\\192.168.211.86\voice</code> uses username/password to map.</p>
  
  <p>All the above practice is run in the same login session.</p>