Running Windows Process in Windows Environment and Returning the Output

Posted on 2007-10-01
Last Modified: 2013-12-13
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!
Question by:8ball629
    LVL 9

    Expert Comment

    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.

    Author Comment

    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.
    LVL 9

    Accepted Solution

    I think you might have an issue with eula: -accepteula should do the trick.
    take a look @ for more info.

    Author Comment

    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.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    Suggested Solutions

    Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
    Both Easy and Powerful How easy is PHP? (  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now