Morning. Im trying to check the state of a service on distant machine, currently im using exec but if machine is unreachable exec sc tries to connect to service forever, without the idea on how to put timeout on exec i found proc_open proc_terminate combination but im having a hard time making it run. I copied the code twiked it a bit but i still have no idea of whats happening with this code. What i want is to run SC and get the result as php variable, in worst case get the output of SC into a file. Currently i have no idea how to make it work the code bellow doesnt write anything to error.txt

PHP Code:
$descriptorspec = array(
    
=> array("pipe""r"),
    
=> array("pipe""w"),
    
=> array("file""lerror.txt""a") ); 
// Create child and start process 
$child = array("process" => null"pipes" => null); 
$child["process"] = proc_open("sc \\999.999.999.999 query Spooler"$descriptorspec$child["pipes"]);