How to start Selenium standalone server from a PHP script?

In my PHP script I am using php-webdriver library with Edge webdriver to get data from a web page and I need to start Selenium standalone server from the script. I copied selenium-server-4.35.0.jar, msedgedriver.exe and NodeWebDriver.json to the current user directory C:Userspnfst, and also created 2 bat files for running hab and for running node: selenium-server-hub.bat and selenium-server-node.bat respectively.

NodeWebDriver.json

{
  "capabilities": [
    {
      "browserName": "MicrosoftEdge",
      "maxInstances": 5,
      "seleniumProtocol": "WebDriver",
      "platform": "WINDOWS"
    },
    {
      "browserName": "firefox",
      "maxInstances": 5,
      "seleniumProtocol": "WebDriver",
      "platform": "WINDOWS"
    },
    {
      "browserName": "chrome",
      "maxInstances": 5,
      "seleniumProtocol": "WebDriver",
      "platform": "WINDOWS"
    },
    {
      "browserName": "internet explorer",
      "maxInstances": 1,
      "seleniumProtocol": "WebDriver",
      "platform": "WINDOWS"
    }
  ],
  "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
  "maxSession": 5,
  "port": 5555,
  "register": true,
  "registerCycle": 5000,
  "hub": "http://Администратор:[email protected]:4444",
  "nodeStatusCheckTimeout": 5000,
  "nodePolling": 5000,
  "role": "node",
  "unregisterIfStillDownAfter": 60000,
  "downPollingLimit": 2,
  "debug": false,
  "servlets": [],
  "withoutServlets": [],
  "custom": {}
}

selenium-server-hub.bat

java -Dwebdriver.edge.driver=msedgedriver.exe -jar ".selenium-server-4.35.0.jar" hub

selenium-server-node.bat

java -Dwebdriver.edge.driver=msedgedriver.exe -jar ".selenium-server-4.35.0.jar" node --config ".NodeWebDriver.json"

Then I tried to start Selenium standalone server from PHP using exec as follows.

Variant 1

$hubCommand = 'C:\Program Files\Java\jdk-24\bin\java.exe -jar "C:\Users\pnfst\selenium-server-4.35.0.jar" hub 2>&1 &';
$nodeCommand = 'C:\Program Files\Java\jdk-24\bin\java.exe -Dwebdriver.edge.driver=C:\Users\pnfst\msedgedriver.exe -jar "C:\Users\pnfst\selenium-server-4.35.0.jar" node --config "C:\Users\pnfst\NodeWebDriver.json" 2>&1 &';
$hubResult = exec($hubCommand, $hubOutput, $hubResult_code);    // start hab
$nodeResult = exec($nodeCommand, $nodeOutput, $nodeResult_code);    // start node

Variant 2

$psHubCommand = 'Start-Process -FilePath "C:\Program Files\Java\jdk-24\bin\java.exe" -ArgumentList "-jar", "selenium-server-4.35.0.jar", "hub" -WorkingDirectory "C:\Users\pnfst" -Verb RunAs';
$psNodeCommand = 'Start-Process -FilePath "C:\Program Files\Java\jdk-24\bin\java.exe" -ArgumentList "-Dwebdriver.edge.driver=msedgedriver.exe", "-jar", "selenium-server-4.35.0.jar", "node", "--config", ".\NodeWebDriver.json" -WorkingDirectory "C:\Users\pnfst" -Verb RunAs';
$hubCommand = "powershell.exe -NonInteractive -NoProfile -ExecutionPolicy Bypass -Command " . escapeshellarg($psHubCommand) . " 2>&1 &";
$nodeCommand = "powershell.exe -NonInteractive -NoProfile -ExecutionPolicy Bypass -Command " . escapeshellarg($psNodeCommand) . " 2>&1 &";
$hubResult = exec($hubCommand, $hubOutput, $hubResult_code);    // start hab
$nodeResult = exec($nodeCommand, $nodeOutput, $nodeResult_code);    // start node

Variant 3

$psHubCommand = 'Start-Process -FilePath "C:\Windows\system32\cmd.exe" -ArgumentList "/c", "C:\Users\pnfst\selenium-server-hub.bat" -WorkingDirectory "C:\Users\pnfst" -Verb RunAs';
$psNodeCommand = 'Start-Process -FilePath "C:\Windows\system32\cmd.exe" -ArgumentList "/c", "C:\Users\pnfst\selenium-server-node.bat" -WorkingDirectory "C:\Users\pnfst" -Verb RunAs';
$hubCommand = "powershell.exe -NonInteractive -NoProfile -ExecutionPolicy Bypass -Command " . escapeshellarg($psHubCommand) . " 2>&1 &";
$nodeCommand = "powershell.exe -NonInteractive -NoProfile -ExecutionPolicy Bypass -Command " . escapeshellarg($psNodeCommand) . " 2>&1 &";
$hubResult = exec($hubCommand, $hubOutput, $hubResult_code);    // start hab
$nodeResult = exec($nodeCommand, $nodeOutput, $nodeResult_code);    // start node

All variants return result code 0 and don’t start hab and node. Variant 2 throws with PowerShell MissingArgument (hub command) and PositionalParameterNotFound (node command) exceptions.
How to properly start a Selenium standalone server from PHP?