![]() |
Bearsampp 2026.5.5
|
Static Public Member Functions | |
| static | countFilesFolders ($path) |
| static | countFilesFoldersCOM ($path) |
| static | createShortcut ($shortcutPath, $targetPath, $workingDir='', $description='', $iconPath='') |
| static | findProcessesByName ($name, $properties=[]) |
| static | getCurrentPid () |
| static | getDefaultBrowser () |
| static | getInstalledBrowsers () |
| static | getProcessInfo ($pid, $properties=[]) |
| static | getProcessList ($properties=[]) |
| static | getServiceInfo ($serviceName, $properties=[]) |
| static | getServiceState ($serviceName) |
| static | getSpecialFolderPath ($folderName) |
| static | killProcess ($pid) |
| static | listServices ($properties=[]) |
| static | processExists ($pid) |
| static | registryDeleteKey ($hive, $key) |
| static | registryDeleteValue ($hive, $key, $value) |
| static | registryExists ($hive, $key, $value=null) |
| static | registryGetValue ($hive, $key, $value='') |
| static | registrySetValue ($hive, $key, $value, $data, $type='REG_SZ') |
| static | resetConnections () |
| static | serviceExists ($serviceName) |
Static Private Member Functions | |
| static | countFilesFoldersManual ($path) |
| static | countFolderItemsCOM ($fso, $path) |
| static | extractBrowserExecutablePath ($commandPath) |
| static | getWmiCimv2 () |
| static | getWmiStdRegProv () |
| static | getWscriptShell () |
| static | mapRegistryHive ($hive) |
Static Private Attributes | |
| static COM | $wmiCimv2 = null |
| static COM | $wmiStdRegProv = null |
| static COM | $wscriptShell = null |
Class Win32Native
This class provides native Windows operations using PHP COM extension. Replaces VBScript operations with direct COM/WMI access from PHP. Uses Windows Management Instrumentation (WMI) and WScript.Shell COM objects.
Definition at line 16 of file class.win32native.php.
|
static |
Counts files and folders recursively using native PHP. Replaces VBS with native PHP (faster than COM FileSystemObject).
| string | $path | The path to count files and folders in |
Definition at line 749 of file class.win32native.php.
References countFilesFoldersManual(), Log\debug(), and Log\error().
|
static |
Counts files and folders recursively using COM FileSystemObject. Alternative COM-based implementation (slower than native PHP).
| string | $path | The path to count files and folders in |
Definition at line 835 of file class.win32native.php.
References countFolderItemsCOM(), Log\debug(), and Log\error().
|
staticprivate |
Manual recursive file/folder counting (fallback method). Helper method for countFilesFolders.
| string | $path | The path to count |
Definition at line 797 of file class.win32native.php.
References countFilesFoldersManual().
Referenced by countFilesFolders(), and countFilesFoldersManual().
|
staticprivate |
Recursive helper for COM-based file/folder counting. Helper method for countFilesFoldersCOM.
| COM | $fso | FileSystemObject instance |
| string | $path | The path to count |
Definition at line 870 of file class.win32native.php.
References countFolderItemsCOM().
Referenced by countFilesFoldersCOM(), and countFolderItemsCOM().
|
static |
Creates a Windows shortcut using COM. Replaces VBS with direct COM access.
| string | $shortcutPath | Full path where to save the shortcut (.lnk file) |
| string | $targetPath | Path to the target executable |
| string | $workingDir | Working directory for the shortcut |
| string | $description | Shortcut description |
| string | $iconPath | Path to icon file |
Definition at line 696 of file class.win32native.php.
References Log\debug(), Log\error(), getWscriptShell(), and resetConnections().
Referenced by Util\enableLaunchStartup().
|
staticprivate |
Extracts the executable path from a browser command string. Helper method for browser detection.
| string | $commandPath | The command path string from registry |
Definition at line 1227 of file class.win32native.php.
Referenced by getInstalledBrowsers().
|
static |
Finds processes by name.
| string | $name | Process name (e.g., 'notepad.exe') |
| array | $properties | Properties to retrieve |
Definition at line 281 of file class.win32native.php.
References $proc, $result, Log\error(), getWmiCimv2(), and resetConnections().
|
static |
Gets the current PHP process ID.
Definition at line 330 of file class.win32native.php.
|
static |
Gets the default browser's executable path using COM. Replaces VBS with direct COM registry access.
Definition at line 1094 of file class.win32native.php.
References Log\debug(), and registryGetValue().
Referenced by ActionReload\__construct(), and ActionStartup\checkBrowser().
|
static |
Gets a list of installed browsers using hybrid approach. Hybrid approach - known browsers + pattern matching (NO VBS!)
Definition at line 1130 of file class.win32native.php.
References Log\debug(), extractBrowserExecutablePath(), and registryGetValue().
Referenced by ActionChangeBrowser\__construct().
|
static |
Gets information about a specific process by PID.
| int | $pid | The process ID |
| array | $properties | Properties to retrieve |
Definition at line 236 of file class.win32native.php.
References $proc, $result, Log\error(), getWmiCimv2(), and resetConnections().
|
static |
Gets a list of running processes using COM/WMI. Replaces VBS WMI process query with direct PHP COM access.
| array | $properties | Optional array of properties to retrieve (e.g., ['Name', 'ProcessID', 'ExecutablePath']) |
Definition at line 85 of file class.win32native.php.
References $proc, $result, Log\debug(), Log\error(), getWmiCimv2(), and resetConnections().
Referenced by Win32Ps\getListProcs().
|
static |
Gets information about a Windows service using COM/WMI. Replaces VBS with direct COM/WMI access.
| string | $serviceName | The name of the service |
| array | $properties | Optional array of properties to retrieve |
Definition at line 903 of file class.win32native.php.
References $result, Log\debug(), Log\error(), getWmiCimv2(), and resetConnections().
Referenced by Nssm\infos(), and Win32Service\infos().
|
static |
Gets the state of a Windows service. Additional helper method.
| string | $serviceName | The name of the service |
Definition at line 1060 of file class.win32native.php.
References getWmiCimv2(), and resetConnections().
Referenced by ActionLoading\checkAllServicesStarted().
|
static |
Gets a Windows special folder path using COM. Replaces VBS with direct COM access.
| string | $folderName | The special folder name (Desktop, Startup, etc.) |
Definition at line 654 of file class.win32native.php.
References Log\debug(), Log\error(), getWscriptShell(), and resetConnections().
Referenced by Util\getStartupLnkPath().
|
staticprivate |
Returns the cached WMI cimv2 connection, creating it on first use.
Definition at line 37 of file class.win32native.php.
Referenced by findProcessesByName(), getProcessInfo(), getProcessList(), getServiceInfo(), getServiceState(), killProcess(), listServices(), processExists(), and serviceExists().
|
staticprivate |
Returns the cached WMI StdRegProv connection, creating it on first use.
Definition at line 48 of file class.win32native.php.
Referenced by registryExists().
|
staticprivate |
Returns the cached WScript.Shell object, creating it on first use.
Definition at line 59 of file class.win32native.php.
Referenced by createShortcut(), getSpecialFolderPath(), registryDeleteKey(), registryDeleteValue(), registryExists(), registryGetValue(), and registrySetValue().
|
static |
Kills a process by PID using COM/WMI. Replaces VBS WMI process termination with direct PHP COM access.
| int | $pid | The process ID to kill |
Definition at line 141 of file class.win32native.php.
References $proc, Log\debug(), Log\error(), getWmiCimv2(), and resetConnections().
Referenced by Win32Ps\kill(), and ActionQuit\terminatePhpProcesses().
|
static |
Lists all Windows services using COM/WMI. Additional helper method.
| array | $properties | Optional array of properties to retrieve |
Definition at line 973 of file class.win32native.php.
References $result, Log\debug(), Log\error(), getWmiCimv2(), and resetConnections().
|
staticprivate |
Maps registry hive abbreviations to full names for WScript.Shell.
| string | $hive | The registry hive (HKLM, HKCU, HKCR, HKU) |
Definition at line 345 of file class.win32native.php.
Referenced by registryDeleteKey(), registryDeleteValue(), registryExists(), registryGetValue(), and registrySetValue().
|
static |
Checks if a process with the given PID exists.
| int | $pid | The process ID to check |
Definition at line 206 of file class.win32native.php.
References $proc, getWmiCimv2(), and resetConnections().
|
static |
Deletes a registry key and all its subkeys using COM. Additional helper method for key deletion.
| string | $hive | The registry hive (HKLM, HKCU, etc.) |
| string | $key | The registry key path to delete |
Definition at line 612 of file class.win32native.php.
References Log\debug(), Log\error(), getWscriptShell(), mapRegistryHive(), and resetConnections().
Referenced by Registry\setValue().
|
static |
Deletes a value from the Windows registry using COM. Replaces VBS/reg.exe with direct COM access.
| string | $hive | The registry hive (HKLM, HKCU, etc.) |
| string | $key | The registry key path |
| string | $value | The value name to delete |
Definition at line 569 of file class.win32native.php.
References Log\debug(), Log\error(), getWscriptShell(), mapRegistryHive(), and resetConnections().
Referenced by Registry\setValue().
|
static |
Checks if a registry key or value exists using COM. Replaces VBS/reg.exe with direct COM access.
Uses StdRegProv for key existence checks (more reliable than WScript.Shell::RegRead). Uses WScript.Shell::RegRead for value existence checks.
| string | $hive | The registry hive (HKLM, HKCU, etc.) |
| string | $key | The registry key path |
| string | null | $value | The value name (null to check key existence only) |
Definition at line 373 of file class.win32native.php.
References Log\debug(), Log\error(), getWmiStdRegProv(), getWscriptShell(), mapRegistryHive(), and resetConnections().
Referenced by Registry\exists().
|
static |
Gets a value from the Windows registry using COM. Replaces VBS/reg.exe with direct COM access.
| string | $hive | The registry hive (HKLM, HKCU, etc.) |
| string | $key | The registry key path |
| string | $value | The value name (empty string for default value) |
Definition at line 473 of file class.win32native.php.
References $result, Log\debug(), getWscriptShell(), and mapRegistryHive().
Referenced by getDefaultBrowser(), getInstalledBrowsers(), Registry\getValue(), and Registry\setValue().
|
static |
Sets a value in the Windows registry using COM. Replaces VBS/reg.exe with direct COM access.
| string | $hive | The registry hive (HKLM, HKCU, etc.) |
| string | $key | The registry key path |
| string | $value | The value name |
| mixed | $data | The data to write |
| string | $type | The registry type (REG_SZ, REG_EXPAND_SZ, REG_DWORD, REG_BINARY) |
Definition at line 521 of file class.win32native.php.
References Log\debug(), Log\error(), getWscriptShell(), mapRegistryHive(), and resetConnections().
Referenced by Registry\setValue().
|
static |
Clears all cached COM connections. Call this after a COM operation fails so the next call gets a fresh connection.
Definition at line 71 of file class.win32native.php.
Referenced by createShortcut(), findProcessesByName(), getProcessInfo(), getProcessList(), getServiceInfo(), getServiceState(), getSpecialFolderPath(), killProcess(), listServices(), processExists(), registryDeleteKey(), registryDeleteValue(), registryExists(), registrySetValue(), and serviceExists().
|
static |
Checks if a Windows service exists. Additional helper method.
| string | $serviceName | The name of the service |
Definition at line 1029 of file class.win32native.php.
References getWmiCimv2(), and resetConnections().
|
staticprivate |
Definition at line 26 of file class.win32native.php.
|
staticprivate |
Definition at line 29 of file class.win32native.php.
|
staticprivate |
Definition at line 32 of file class.win32native.php.