|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-09-28 22:27 UTC] steve at qzed dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 18:00:01 2025 UTC |
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