Jump to content

[SOLVED] Process ID


Asheeown

Recommended Posts

I need to get the process ID of a background process I'm executing and I can't seem to get it.

OS: Windows

 

$dir = "C:/xampp/php";
$php_path = "C:/xampp/php/php.exe";
$file = "myscript.php";
$cmd_options = "-t " . time();
$wscript = new COM('WScript.Shell');
$Command = $wscript->Run("$php_path $dir/$file", 0, false);

 

Any ideas?

Link to comment
Share on other sites

Basically, I want to access one of the properties of the COM Object.

 

Now, com_get would work fantastic, however it has been discontinued ever since php5, this is the note that comes along with the manual for COM_GET

 

Note:  This function does not exist in PHP 5; instead, you should use the regular and more natural OO syntax to access properties or call methods.

 

If anyone could point me in the direction of how to write an OO syntax for this situation it would be the most amazing thing ever.

Link to comment
Share on other sites

Fatal error: Uncaught exception 'com_exception' with message 'Unable to lookup `ProcessId': Unknown name. ' in C:\xampp\htdocs\EGM\test.php:12 Stack trace: #0 C:\xampp\htdocs\EGM\test.php(12): unknown() #1 {main} thrown in C:\xampp\htdocs\EGM\test.php on line 12

 

$dir = "C:/xampp/php";
$php_path = "C:/xampp/php/php.exe";
$file = "myscript.php";
$cmd_options = "-t " . time();
$wscript = new COM('WScript.Shell');
$Command = $wscript->Run("$php_path $dir/$file", 0, false);
$PID = $wscript->ProcessId;
echo $PID;

 

Everything works fine until I add the $PID = $wscript->ProcessId; in.

Link to comment
Share on other sites

Keep in mind, I believe with windows there is no process memory... Each new opened process is just given a consecutive process ID... Meaning if you're looking for a specific program, to grab output maybe via PID, then you might (in a second script run) be polling the wrong program for the right information. :P

 

Just something to think about. :)

Link to comment
Share on other sites

Okay I'll leave it with another question.

 

If in the same script as executing the background script did I run a tasklist command that pulled an entire list of processes could I pull the PID from there?

Meaning that once the script has executed the list command will run and php will grab the absolute last process called "php.exe" and get it's PID since processes are listed in order of executed on tasklist.

Would this work or if someone executed at the same time as someone else could the PIDs get mixed up?  Please someone answer this question since it's based on pure logic and doesn't have anything to do with Windows or Linux OS.  Thank you.

Link to comment
Share on other sites

NO ONE can answer that question?  Really?  I see people post the absolute dumbest questions on this forum and still get answers, I post a simple logic question and it just gets passed by?  I leave posts for days but it doesn't matter, 10 minutes after I bump it 90% dumb topics cover it up and throw it off to the next page.

 

 

I would love a simple yes or no answer to my question I posted above, I'll quote it every day until I get an answer.

Link to comment
Share on other sites

The reason why no one has answered your question is that you basically demand it be answered. If you yell at someone: "Do this, do that!" reguardless of who you are and your reasons for being so pushy - no one is going to want to do or answer.

Link to comment
Share on other sites

Did you happen to take a look at the 14 other posts before that one?  Oh yeah they were bumps, DAYS apart from each other, it just gets a little annoying when you ask a logical question that someone could simply answer yet they just don't look or post something stupid like your post relating absolutely nothing towards the topic just here to be a dick.  So please don't post if you don't have anything beneficial to contribute.

Link to comment
Share on other sites

I hate when people get demanding.  I must say I agree with Xanza.  I don't mind bumps, in fact I encourage them because things need to get answered.  A simple "bump" or "Please help" works fine.  A "F------ HELP ME NOW" just pisses people off.    I have no experience with COM objects, but try a var_dump on it and see if you can find the property you want in the list.

Link to comment
Share on other sites

I hate when people get demanding.  I must say I agree with Xanza.  I don't mind bumps, in fact I encourage them because things need to get answered.  A simple "bump" or "Please help" works fine.  A "F------ HELP ME NOW" just pisses people off.    I have no experience with COM objects, but try a var_dump on it and see if you can find the property you want in the list.

 

Exactly, I have no experience with COM either.  Hopefully someone does, but I doubt it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.