Beispiel #1
0
 /**
  * Function deletes a value from the registry
  * @param <string> $folder Folder of the registry value
  * @param <string> $key Key of the registry
  * @return <boolean> Whether registry was successfully deleted to or not
  * @category Extra
  * <code>
  *  $result = Extra::deleteRegistry('registry\\path', 'key');
  * </code>
  */
 function deleteRegistry($folder, $key)
 {
     try {
         $WshShell = new COM("Wscript.shell");
         $registry = "HKEY_LOCAL_MACHINE\\SOFTWARE\\" . $folder . "\\" . $key;
         $result = $WshShell->RegDelete($registry);
         echo $key . " is successfully deleted from HKEY_LOCAL_MACHINE\\SOFTWARE\\" . $folder;
         return $result;
     } catch (Exception $err) {
         return $err->getMessage();
     }
     return FALSE;
 }
Beispiel #2
0
function phpreg()
{
    $shell1 = new COM("wscript.shell") or die("require windows host");
    $action = isset($_POST['action']) ? $_POST['action'] : '';
    echo '<div class="actall"><h5>Windows注册表读写</h5></div>';
    print <<<END
<TR><form action="" method="post">   
<div class="actall"><TD WIDTH=100 VALIGN=TOP ALIGN=CENTER>   
路径:<input type="hidden" name="action" value="读取">   
<input type="text" name="rpath" value="{$rpath}" size="70">   
<input class="bt" type="submit" value="读取"></form><br></TD></TR></div>   
END;
    $rpath = isset($_POST['rpath']) ? $_POST['rpath'] : '';
    $rpath = str_replace("\\\\", "\\", $rpath);
    if ($action == "read") {
        $out = $shell1->RegRead($rpath);
        echo '<pre>' . var_dump($out) . '</pre>';
    }
    print <<<END
<TR><form action="" method="post">   
<div class="actall"><TD WIDTH=100 VALIGN=TOP ALIGN=CENTER>位置:<input type="text" name="wpath" value="{$wpath}" size="70"><BR><br> 
类型:<input type="text" name="wtype" value="{$wtype}" size="20"> 值:<input type="text" name="wvalue" value="{$wvalue}" size="30">
<input type="hidden" name="action" value="write"><input class="bt" type="submit" value="写入"></form></TD></TR></div>   
END;
    $wpath = isset($_POST['wpath']) ? $_POST['wpath'] : '';
    $wpath = str_replace("\\\\", "\\", $wpath);
    $wtype = isset($_POST['wtype']) ? $_POST['wtype'] : '';
    $wvalue = isset($_POST['wvalue']) ? $_POST['wvalue'] : '';
    if ($action == "write") {
        $shell1->RegWrite($wpath, $wvalue, $wtype);
    }
    print <<<END
<TR><form action="" method="post">   
<div class="actall"><TD WIDTH=100 VALIGN=TOP ALIGN=CENTER>  
位置:<input type="hidden" name="action" value="del">   
<input type="text" name="dpath" value="{$dpath}" size="70">   
<input class="bt" type="submit" value="删"></form></TD></TR></div>   
END;
    $dpath = isset($_POST['dpath']) ? $_POST['dpath'] : '';
    $dpath = str_replace("\\\\", "\\", $dpath);
    if ($action == "del") {
        $out = $shell1->RegDelete($dpath);
    }
}
Beispiel #3
0
 public function delete($key)
 {
     try {
         $result = $this->shell->RegDelete($registry);
         return $result;
     } catch (Exception $e) {
         echo "Delete Registry Key : {$key} error." . PHP_EOL;
         echo "Exception Code " . $e->getCode() . PHP_EOL;
         echo "Exception Message : " . $e->getMessage() . PHP_EOL;
     }
     return false;
 }