Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Running Windows Process in Windows Environment and Returning the Output

Posted on 2007-10-01
Medium Priority
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
  • 2
  • 2

Expert Comment

ID: 19993743
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

ID: 19994641
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.

Accepted Solution

paradoxengine earned 2000 total points
ID: 19994702
I think you might have an issue with eula: -accepteula should do the trick.
take a look @ http://forum.sysinternals.com/printer_friendly_posts.asp?TID=9345 for more info.

Author Comment

ID: 19996516
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo‚Ķ
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

580 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