Link to home
Start Free TrialLog in
Avatar of 8ball629
8ball629Flag for United States of America

asked on

Running Windows Process in Windows Environment and Returning the Output

I'm currently working on a project where I'm running PHP on a Windows 2000 server on IIS and I'm trying to run a process on the server and return the output.  I've tried multiple techniques including all of the shell, exec, etc. functions to no avail.  I've also tried the Run and Exec Methods (Windows Script Host).

What happens is when I try to run the process, it seems to run but then PHP waits for the command to finish executing or close before the script continues.  This is not a problem with commands such as "dir" but the specific process I'm trying to run is pslist.exe from the PsTools package for Windows.

The furthest I got was printing out the output of "dir" using the Exec Windows Script Host Method.

Thanks in advance!
Avatar of paradoxengine
paradoxengine
Flag of Italy image

Have you played with the maximum running time of the script in php.ini? It might be that causing the error.
Anyway, keep in mind the restrictions imposed to the user running the command: it's not SYSTEM, is it :) ? I mean, for security reasons it should be an unprivileged user, thus unable to access most features in the operating system, like a complete process list.
Avatar of 8ball629

ASKER

I've decided to use the Windows 2000 Support Tools package with tlist.exe to get the list of processes and that happens without a hitch.  Now my issue is killing a process.  I've tried kill.exe and it doesn't kill all processes that I want it to kill due to permissions I'm guessing.

I have a feeling that pskill.exe from the PSTools will work but those hang when I try to use shell_exec( ) to start them.  I'm using the same function for tlist.exe and kill.exe but they don't hang so I'm really confused as to why it would hang on one but not the other when they're practically the same programs.
ASKER CERTIFIED SOLUTION
Avatar of paradoxengine
paradoxengine
Flag of Italy image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks paradoxengine.  

Somehow through my 2 days of endless searching on the web I missed that one.  If only it were documented as an option in the command line when you run the program ;).  After that I was still getting problems with not being able to kill certain processes so I ended up passing in admin user login creditentials and that wrapped it up.