Skip to content

Bug: Environment variables specifications are not expand/evaluated in shortcuts before execution #14410

Closed
@clackwell

Description

@clackwell

Description

In Windows shortcuts I can use, for example, "%USERPROFILE%" (a specification of an environment variable, supported in cmd.exe/batch files) in the shortcut fields "Target:" and "Start in:"

295237396-ca228625-72c0-4b83-a6d2-83cf87b655a9

But when executing such a shortcut via double click in Files, one can see that the process gets launched with the environment specification as is, instead of evaluated. From Process Explorer:

295239103-471f988b-9a2c-4061-a7ba-0e0e418f67e2

The top entry is when launched from File Explorer.

The bottom entry is when launched from Files. Note the command line, which for the bottom entry still contains the environment variable placeholder.

I suspect that expansion of environment variable specifications may be functionality of the underlying Win32 (or so) API used.

When launching the shortcut in cmd.exe, the expansion happens. One could suspect that cmd.exe has extra functionality to achieve this however.

When using Python, and executes the shortcut via os.system(), the expand happens, too.

Steps To Reproduce

  1. Create a shortcut and in its properties set/change its "Target:" field to:

%WINDIR%\notepad.exe

  1. Double click the shortcut in File Explorer.

Expected and actual result: Notepad(.exe) launches.

  1. Double lick the shortcut in Files.

Expected result: Notepad.exe launches.

Actual result: Notepad does not launch.

Requirements

Notepad.exe gets launched as expected.

Files Version

3.1.1

Windows Version

10.0.22631.2861

Log File

debug.log

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood issue for new contributors to get started with

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions