php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30265 Can access properties but no methods of Win32_Process object
Submitted: 2004-09-28 20:36 UTC Modified: 2004-09-28 22:27 UTC
From: steve at qzed dot com Assigned:
Status: Not a bug Package: COM related
PHP Version: 4.3.8 OS: Windows 2000
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
26 - 7 = ?
Subscribe to this entry?

 
 [2004-09-28 20:36 UTC] steve at qzed dot com
Description:
------------
I am using the COM object of PHP to access WMI.  
I can access Win32_Process objects and display their property values.
When I try to use Win32_Process method SetPriority I get a PHP error: 'Unable to lookup setpriority: Unknown name.'

Reproduce code:
---------------
<?php

   set_time_limit(0);

   $shell = new COM("WScript.Shell");

   $cmd = 'php.exe st1.php';
   $st1 = $shell->Exec($cmd);

   echo $cmd." Started as ProcessID ".$st1->ProcessID."\n";

   $wmi = new COM('WinMgmts:{impersonationLevel=impersonate}!//./root/cimv2');

   $query = "Select * from Win32_Process where ProcessID = ".$st1->ProcessID;

   $stillRunning = true;
  
   while ($stillRunning) {

      $stillRunning = False;

      $processes = $wmi->ExecQuery($query);

      while ($process = $processes->Next()) {

         if ($process->ProcessID == $st1->ProcessID)  {
            echo "process ".$process->ProcessID." still running\n";
            echo "process ".$process->ProcessID." priority is ".$process->Priority."\n";

            $priority = 128;
            $process->SetPriority($priority); //high 

            $stillRunning = true;            
         }
      }

      sleep(2);
   }


   echo "process ".$st1->ProcessID." ended";

?>

Expected result:
----------------
D:\d2>php tm.php
Content-type: text/html
X-Powered-By: PHP/4.3.8

php.exe st1.php Started as ProcessID 1052
process 1052 still running
process 1052 priority is 8
process 1052 still running
process 1052 priority is 8
process 1052 still running
process 1052 priority is 8
^C

Actual result:
--------------
D:\d2>php tm.php
Content-type: text/html
X-Powered-By: PHP/4.3.8

php.exe st1.php Started as ProcessID 1488
process 1488 still running
process 1488 priority is 8
<br />
<b>Warning</b>:  (null)(): Unable to lookup setpriority: Unknown name.
 in <b>D:\d2\tm.php</b> on line <b>31</b><br />
process 1488 still running
process 1488 priority is 8
<br />
<b>Warning</b>:  (null)(): Unable to lookup setpriority: Unknown name.
 in <b>D:\d2\tm.php</b> on line <b>31</b><br />
process 1488 still running
process 1488 priority is 8
<br />
<b>Warning</b>:  (null)(): Unable to lookup setpriority: Unknown name.
 in <b>D:\d2\tm.php</b> on line <b>31</b><br />
process 1488 still running
process 1488 priority is 8
<br />
<b>Warning</b>:  (null)(): Unable to lookup setpriority: Unknown name.
 in <b>D:\d2\tm.php</b> on line <b>31</b><br />
^C

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-09-28 22:27 UTC] steve at qzed dot com
This isn't an issue with PHP.

The SetPriority method on the Win32_Process Method is only available on Windows XP and Windows 2003.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 23:01:28 2024 UTC