2

OK, having issues. My PHP script works except for 1 line.
This line tries to execute an outside command with exec().

I get:

Warning: exec(): Unable to fork

I tried searching for an answer. Several sites say I have to set the permissions on cmd.exe. Whether I do that in system32 or syswow64, I'm not sure.

Also not sure what user to add. ISUR or the user (lime) I get from get_current_user().

Windows won't let me add any users to the security list (right click on file, properties, security, edit).

It also won't let me use icacls cmd.exe /grant IUSR:F (access denied in system32)(The handle is invalid in syswow64)

I've already added full access rights (ISUR, SYSTEM, SERVICE, NETWORK SERVICE, lime, Everyone, and IIS_ISURS) to the folder where a file will be created. I realize this is overkill, and have to pare this down.

I'm going to have to do this in both Windows 7x64 (dev machine) & Windows Server 2012 (production).

So many examples I find are either geared for previous systems, or don't go into enough details.

Can someone please help me? I need to get the script working. Thanks

Will
  • 24,082
  • 14
  • 97
  • 108
Tom Collins
  • 4,069
  • 2
  • 20
  • 36

1 Answers1

2

You do not provide enough information to answer your question...

If your PHP script is going to be executed in a Windows OS, perhaps you could have a look at the COM functions, instead of exec(). COM functions will give you way more control over what you're trying to do (Office automation, perhaps?)

COM is much more powerful than exec(), as it allows you to control the resulting application window itself, if there is one. For example, you can start a new process with an invisible window, or a minimized window.

Some examples can be found in the PHP exec() page itself.

Basically, you can do something like the following, to get an application running:

$shell = new COM("WScript.Shell");
$shell->Run("notepad.exe");
$shell = null;

Googling for "php WScript.Shell" will yield a lot of results on the subject.

Edit: Also, you'll need to add this into your IIS web.config:

<identity impersonate="true" userName="youruser" password="yourpass"/>`

This will set the user that IIS will impersonate when launching processes.

Filippos Karapetis
  • 4,367
  • 21
  • 39