|
@@ -1,7 +1,7 @@
|
|
|
<?php
|
|
|
namespace DistributeHelper;
|
|
|
error_reporting(E_ALL & ~E_NOTICE);
|
|
|
-include "Utility.php";
|
|
|
+//include "Utility.php";
|
|
|
|
|
|
class WscriptShell
|
|
|
{
|
|
@@ -102,11 +102,11 @@ class WinEnvPath extends WscriptShell
|
|
|
{
|
|
|
WscriptShell::__construct();
|
|
|
}
|
|
|
- public function readPath()
|
|
|
+ public static function readPath()
|
|
|
{
|
|
|
return self::RegRead(self::$KEY_PATH);
|
|
|
}
|
|
|
- public function updatePath(array $removePatterns ,array $addPathes)
|
|
|
+ public static function updatePath(array $removePatterns ,array $addPathes)
|
|
|
{
|
|
|
$envPath = self::RegRead(self::$KEY_PATH);
|
|
|
if($envPath === false){
|
|
@@ -116,7 +116,7 @@ class WinEnvPath extends WscriptShell
|
|
|
$newPath = self::addPath($newPath,$addPathes);
|
|
|
return $shell->RegWrite(self::$KEY_PATH,$newPath,'REG_EXPAND_SZ');
|
|
|
}
|
|
|
- private function isPattern(string $path,array $patterns)
|
|
|
+ private static function isPattern(string $path,array $patterns)
|
|
|
{
|
|
|
foreach($patterns as $pattern){
|
|
|
if(strpos($path,$pattern) !== false){
|
|
@@ -125,7 +125,7 @@ class WinEnvPath extends WscriptShell
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
- private function removePath(string $envPath,array $patterns)
|
|
|
+ private static function removePath(string $envPath,array $patterns)
|
|
|
{
|
|
|
$array = explode(';',$envPath);
|
|
|
$result = array();
|
|
@@ -136,7 +136,7 @@ class WinEnvPath extends WscriptShell
|
|
|
}
|
|
|
return implode(';',$result);
|
|
|
}
|
|
|
- private function addPath(string $envPath,array $addPathes)
|
|
|
+ private static function addPath(string $envPath,array $addPathes)
|
|
|
{
|
|
|
$array = explode(';',$envPath);
|
|
|
$result = array_merge($array,$addPathes);
|
|
@@ -147,12 +147,11 @@ class WinEnvPath extends WscriptShell
|
|
|
//windows系统自启动操作类
|
|
|
class WinAutorun extends WscriptShell
|
|
|
{
|
|
|
- private $shell = null;
|
|
|
public function __construct()
|
|
|
{
|
|
|
WscriptShell::__construct();
|
|
|
}
|
|
|
- public function remove($name)
|
|
|
+ public static function remove($name)
|
|
|
{
|
|
|
$shell = self::$shell;
|
|
|
if(! $shell){
|
|
@@ -165,14 +164,14 @@ class WinAutorun extends WscriptShell
|
|
|
}
|
|
|
try{
|
|
|
$key = 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\\' . $name;
|
|
|
- $shell->RegDelete($key;
|
|
|
+ $shell->RegDelete($key);
|
|
|
return true;
|
|
|
} catch (Exception $e) {
|
|
|
logError('failed to removeAutorun',$e->getCode(),$e->getMessage());
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
- public function register($name,$cmd)
|
|
|
+ public static function register($name,$cmd)
|
|
|
{
|
|
|
$shell = self::$shell;
|
|
|
if(! $shell){
|
|
@@ -205,7 +204,7 @@ class WinDesktopShortcut extends WscriptShell
|
|
|
{
|
|
|
WscriptShell::__construct();
|
|
|
}
|
|
|
- public function remove($shortcutName)
|
|
|
+ public static function remove($shortcutName)
|
|
|
{
|
|
|
$desktopFolder = self::getDesktopFolder();
|
|
|
if(! $desktopFolder){
|
|
@@ -217,7 +216,7 @@ class WinDesktopShortcut extends WscriptShell
|
|
|
else
|
|
|
return true;
|
|
|
}
|
|
|
- public function register($shortcutName,$targetPath,$description)
|
|
|
+ public static function register($shortcutName,$targetPath,$description)
|
|
|
{
|
|
|
$desktopFolder = self::getDesktopFolder();
|
|
|
if(! $desktopFolder){
|