title: PHP WMI Query timeout
body: <p>I am scanning a subnet to gather WMI information on assets on the network. However, if a machine is stuck in POST or has some unknown issue, it will freeze the script and never move on to the next machine. Question is, <strong>is there a way to set a timeout on PHP COM WbemScripting.SWbemLocator?</strong></p>
  
  <pre><code>    $host = 10.1.1.5; //Host is online, but may be hung trying to shutdown
  
      //Check if host is online
      if(@$fp = fsockopen($host,135,$errCode,$errStr,0.1))
      {
          //Create new connection
          $WbemLocator = new COM ("WbemScripting.SWbemLocator");
  
          //Connect to remote workstation
          $WbemServices = $WbemLocator-&gt;ConnectServer($host, 'root\\cimv2',$user,$password);  
          $WbemServices-&gt;Security_-&gt;ImpersonationLevel = 3;
  
          //Basic WMI query
          $system = $WbemServices-&gt;execQuery("Select * from Win32_ComputerSystem");   
  
          foreach($pcsystem AS $n){
  
              $hostname = $n-&gt;Name; //Hostname
  
          }
  
          //Process all data -&gt;Insert into DB
      }
  //Move on to next machine. In this case, the script will never move on
  </code></pre>