note 52681 deleted from ref.com by cmb

From: Date: Sun, 30 Jun 2019 08:01:23 +0000
Subject: note 52681 deleted from ref.com by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-211425@lists.php.net to get a copy of this message
Note Submitter: mpg123 at thinstall dot com ---- I found the lack of good online docs about how to access a windows environment very frustrating. I finally found something here: http://www.sitepoint.com/forums/showthread.php?t=92358 but it's a php4 way. I cleaned up the code, added introspection for methods and voila. Thanks and credit to the original posters. <?php // php translation of asp script by Bill Wooten from // http://www.4guysfromrolla.com/webtech/082802-1.shtml function showServices($vComputerName, $vClass) { $objLocator = new COM("WbemScripting.SWbemLocator"); if($vComputerName == "") $objService = $objLocator->ConnectServer(); else $objService = $objLocator->ConnectServer($vComputerName); $objWEBM = $objService->Get($vClass); $objProp = $objWEBM->Properties_; $objMeth = $objWEBM->Methods_; foreach($objMeth as $methItem) echo "Method: " . $methItem->Name ."\r\n"; echo "\r\n"; $objWEBMCol = $objWEBM->Instances_(); foreach($objWEBMCol as $objItem) { echo "[" . $objItem->Name . "]\r\n"; foreach($objProp as $propItem) { $tmp = $propItem->Name; echo "$tmp: " . $objItem->$tmp . "\r\n"; } echo "\r\n"; } } // Test the function: showServices("", "Win32_Processor"); showServices("", "Win32_LogicalDisk");

« previous php.notes (#211425) next »