Oh sorry...
I just commented the $letter b4 submitting the code here....But Even of we give open_dir("p:") it gives the same error

    See my post above - I noticed a problem with the backslashes.

      I doubt whether this system () command is getting executed or not...

        It's possible that PHP doesn't have access to cmd.exe or net.exe on the Windows system, based on the credentials that it's running under. Try something like this instead:

        $WshNetwork = new COM("WScript.Network");
        $WshNetwork->MapNetworkDrive("$letter:", '\\\\server\name', FALSE, 'username', 'password');

          I am getting following error

          Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> WSHNetwork.MapNetworkDrive<br/><b>Description:</b> A specified logon session does not exist. It may already have been terminated. ' in C:\wamp\www\knet\handle.php:57 Stack trace: #0 C:\wamp\www\knet\handle.php(57): com->MapNetworkDrive('P:', '\192.168.1.5\D...', false, 'USERNAME', 'PASSWORD') #1 {main} thrown in C:\wamp\www\knet\handle.php on line 57

            FYI...

            I have created a Z: drive using COmmand prompt. But I cannot enter into this Z: through open_dir("Z:") whereas I can access any other drive by open_dir("D:\ABC\DEF")

              I'm assuming you replaced 'USERNAME' and 'PASSWORD' with valid credentials?

              Is this running in an Active Directory domain environment? If so, it might be necessary to use the "domain\user" syntax for the username instead of just "user".

                Sir,

                I am pasting the same command in Command promt. Its direct copy paste apart from those backslashes.
                I did not understand "Active Directory domain environment"

                Here this ip (192.168.1.5) is my own IP and Database is a folder share by me only on my system.

                Sir,

                If possible can you just check with this code in your system...as I think I am stuck up with something strange.

                I shall be waiting...

                  Hi,

                  I am unable to access z: through opendir() where z: is already created in through command prompt

                    It's most likely a permissions issue, since the PHP parser isn't running under the same user credentials as you are (more than likely, anyway).

                    There's no way to change this; either have the server administrators modify the user credentials that the PHP process uses, or add the credentials that it does use to the ACL for the shared folder to give it access.

                      So, Sir,
                      The server being in my local machine, I am the server administrator. So how to modify the rights.

                      By the way, are you able to reproduce this defect in your local system, or it is working fine for you

                        dhrubajyoti;10945469 wrote:

                        By the way, are you able to reproduce this defect in your local system, or it is working fine for you

                        The code I posted using a COM object successfully mapped the drive, and is_dir() returned true - I didn't try to use any other file-system functions, though. I also was running the PHP script from the CLI using my own user credentials, though.

                        How is PHP integrated with Apache in WAMP - ISAPI module (the .dll file) or as a CGI binary? You could try to modify the httpd.exe process to run as your own user credentials instead of SYSTEM... here's a quick how-to for that:

                        1. Open the Services MMC by going to Start -> Run (or by using the search box, if using Windows 7) and typing Services.msc and pressing enter.

                        2. Find the Apache service. Having never used WAMP, I have no idea what it's been named. Hopefully it starts with the word "Apache" though, and thus shouldn't be too hard to find.

                        3. Right-click on the service and select Properties.

                        4. Switch to the Log On tab.

                        5. Select the radio button next to "This account:" and enter in the credentials for the user account you want to run Apache under. If it's a network/domain account, use the "DOMAIN\user" syntax (or search for the account using the Browse button).

                        6. Select OK and restart the Apache service.

                        7. Verify that your changes worked by looking for the "httpd.exe" process in Task Manager and checking to see which user name the process is running under.

                          Thanks a lot Sir for your help. Although net use did not work for me, but I could get that resolved thorugh that COM object creation.

                          Thanks a lot.

                            Write a Reply...