Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Process] Windows REG utility not recognized as an internal or external command #44260

Closed
@stable-staple

Description

@stable-staple

Symfony version(s) affected

4.4

Description

The Symphony component "Process" doesn't recognize the environment variable "Path", which leads to the fact that it's impossible to perform operations with the standard Windows utilities and other programs written in the "Path" variable.

How to reproduce

Windows-only: run script from a web server with the following code:

    $registry_path = "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows";
    $pathname = "C:\\example.reg";
    $command = 'reg save ' . '"' . $registry_path . '" "' . $pathname . '"';
    
    $process = Process::fromShellCommandline($command);
    $code = $process->run();

    if (!$process->isSuccessful()) {
        echo 'fail';
    }

Possible Solution

Windows environment variables should be treated case-insensitively. Intersection of $_SERVER with getenv() is performed to get the default envs, but intersection in question is done in a case-sensitive manner, which leads to bugs in Windows.

Additional Context

Bug doesn't reproduce in a command line environment.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions