I am trying to connect to some Windows directories using system(net use...). I works fine on my local machine where I have installed PHP, MySql, Apache... Though, I need to move it to a Windows 8 Server using WAMP. When I try running the script from there it's like it doesn't recognize the system() call and I get the following error:

Warning: opendir(V:/today/,V:/today/) [<a href='function.opendir'>function.opendir</a>]: The system cannot find the path specified. (code: 3) in C:\workspace\www\cameracatcher\camera.php on line 205

Here is my actual call:

$testWH = array(2 => array('WH' => 'ST. Louis', 'IP' => '100.100.2.200', 'DRIVE' => 'V'),
				3 => array('WH' => 'Visalia', 'IP' => '100.100.3.200', 'DRIVE' => 'U')
				);


$camCheck = array();
$doCamCheck = array();
$imgs = array();
$deadCamCheck = array();
$docheck = array();
$countArray = 0;
$countImgs = 0;

//------------------------
//loop through warehouse to check
//------------------------
foreach($testWH as $w=>$h){
//------------------------
//Map the drive 
//------------------------
system('net use '.$h['DRIVE'].': \\\\'.$h['IP'].'\\'.$folder.'\ '.$pass.' /user:'.$user.'/persistent:no'); 

//------------------------
//call func to read thru dir's
//------------------------
$doCamCheck = openMyDir($h['DRIVE'].":/today/", $camCheck, $imgs);
.
.
.

I've tried going into services.msc and changed the Apache user to an admin user instead of the local login user. I also set safe_mode_exec_dir = OFF.

Could this be an issue b/c I am on Windows Server 8 or something w/ the WAMP install?

I appreciate any feedback.

    Looks to me like the most likely culprit is a failure of the "net use" command. Can you somehow verify that "V:" is mapped and accessible before you assign $doCamCheck?

      I have the network drives mapped and I can access the directories fine browsing on the Windows Server 8 box. Then, on my local machine (windows 7.. manual install of PHP) on the same network w/ those mapped drives I can access them w/ the exact script. It seems when I try to run it via WAMP on Windows Server 8 is when it fails. I tried: services.msc > Log On and switched back to Local System and checked "Allow Service to interact with desktop". No luck w/ that either. Is there something I can look at in phpinfo() that would tell me anything about "net use"?

        I don't know about net use in phpinfo(). I kind of doubt it, but I suppose you could try.

        Have you tried adding the return_var param to your system call to see what results from it?

        //------------------------ 
        //Map the drive  
        //------------------------ system('net use '.$h['DRIVE'].': \\\\'.$h['IP'].'\\'.$folder.'\ '.$pass.' /user:'.$user.'/persistent:no', $my_error_var); if ($my_error_var) { //error routine here, write to log, die, exit, throw exception, etc. }

        I just know that I've had many issues for customers over the years (back when I did that stuff) with SAMBA-related sharing issues, and also that Windows maps by user (so, I can do "T:" in my CMD shell here, no problem, but if I run CMD as Administrator it has no idea "T:" exists ...), so I'd think it wise to ensure that this non-persistent drive mapping actually worked before I tried to read or write with it.

          12 days later

          I ended up removing WAMP and manually installed PHP and that solved the issues.

            Write a Reply...