Jump to content

access denied problems with external executable


abacus2015

Recommended Posts

Hi 

 

I have a problem in running an external executable .exe or .bat. For example using the following php code:

 



$abc= system("C:\test\test.bat 2>&1");
printf ("TEST1:");
printf ($abc);
$abc= system("whoami 2>&1");
printf ("TEST2:");
printf ($abc);


 

I get the following result:

   



Access is denied. TEST1:Access is denied.servername\iwam_plesk(default) TEST2:servername\iwam_plesk(default)


 

Obviously the file test.bat exists in the directory C:\test\. And I am running this on a windows 2008 server with access from the web.

 

Any help would be appreciated, thanks!

Link to comment
Share on other sites

Side comment: The path isn't actually C:\test\test.bat, right? You've made sure that you're escaping your backslashes in the path? Because strictly speaking your code is trying to execute C:estest.bat 2>&1.

 

system() goes through cmd.exe. Does the user have execute permissions on that too? And you've verified that it has permissions on whatever test.bat is trying to run?

Link to comment
Share on other sites

Hi there and happy new year!

 

The specific user has execution rights for cmd.exe. In addition I am escaping the backslashes in the path, this does not seem to be the issue.

 

For example if I place the file in the current directory (to avoid the backslashes):

    $abc=system("test.bat 2>&1");
    printf ("TEST1:");
    printf ($abc);
    $abc=system("whoami 2>&1");
    printf ("TEST2:");
    printf ($abc);

assuming that test.bat is just the following:

echo "Hello WOrld!"
print "Hello WOrld!!!!"

I get the following response

TEST1:servername\iwam_plesk(default) TEST2:servername\iwam_plesk(default)

i.e. the test.bat seems to be ignored and does not return anything

 

whereas if I change the code to this (testttt.bat is missing from the current folder):

    $abc=system("testttt.bat 2>&1");
    printf ("TEST1:");
    printf ($abc);
    $abc=system("whoami 2>&1");
    printf ("TEST2:");
    printf ($abc);

I get

'testtttt.bat' is not recognized as an internal or external command, operable program or batch file. TEST1:operable program or batch file.servername\iwam_plesk(default) TEST2:servername\iwam_plesk(default)

I think it is a permissions issue, but I cannot locate the root of the problem.

 

Any advice would be highly appreciated.

Link to comment
Share on other sites

Using 

    $abc=exec("test.bat 2>&1", $abc_output);
    printf ("TEST1:");
    print_r ($abc_output);
    $abc=system("whoami 2>&1");
    printf ("TEST2:");
    printf ($abc);

gives

TEST1:Array ( ) servername\iwam_plesk(default) TEST2:servername\iwam_plesk(default)

so it still seems to return nothing!! this is so strange!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.