Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm running a php script through the webserver to execute psexec which in turns executes another php script.

When I run this from the command line normally, everything works fine and there are no problems.

However, when I run it from the webserver, I get this:

PsExec v1.98 - Execute processes remotely
Copyright (C) 2001-2010 Mark Russinovich
Sysinternals -

php exited with error code 1.

So from this I can obviously tell that psexec is running properly, but for some reason the php script is exiting. Like I said, though, if I run it manually from the command line, it works perfectly.

I tried to do a bit of looking around, but I can't figure it out. Does anyone know?

I'm running Apache2 (XAMPP) on Windows 2008

share|improve this question
up vote 0 down vote accepted

Error codes returned by PsExec are specific to the applications you execute, not PsExec. If psexec successfully connects and runs the target program it will return the errorlevel from that program. 0 is usually success, 1 is usually incorrect/invalid/fail.

What are you trying to accomplish? Maybe you can setup a scheduled task to run the script or some other method of launching it. Maybe the service account running apache does not have execute permissions on the script?

EDIT: also try adding the -accepteula flag to the psexec command in your PHP code. It may be getting hung on accepting the EULA

share|improve this answer
How would I go about giving it execute permissions, or even finding out which account is running apache? – Rob Oct 7 '11 at 19:24
Task manager, show processes from all users. Then Right click the script > properties > security/permissions and add give that account full control. – iainlbc Oct 7 '11 at 19:27
I had the accepteula problem prior to this, but another helpful user helped me solve that. I'll look into the execution permissions – Rob Oct 7 '11 at 19:29
It's also possible apache account doesn't have permissions to execute psexec. Can you launch something else like Notepad from your php code? relevant, you might want to try this registry modification (2nd post from bottom):… – iainlbc Oct 7 '11 at 19:32
As for your first idea: apache does seem to have permissions to execute everything. The PHP script seems to execute psexec just fine, but then psexec gets an error code from the php script that psexec executes. (Hope you could follow all that, it got a bit repetitive) – Rob Oct 7 '11 at 19:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.