Is it safe to use %w

nkgc 1 Reputation point
2020-10-05T03:00:09.283+00:00

Hi.
I wanted to open .sh file with windows terminal. So I changed my registry.

[HKCR\.sh]
@ = sh_auto_file
[HKCR\sh_auto_file\shell\open\command]
@ = "C:\Users\rlcks\AppData\Local\Microsoft\WindowsApps\wt.exe" -p "Command Prompt" "C:\Program Files\Git\bin\bash.exe" "%L" %*

But this registry open .sh file in my home directory not a directory where the file is. So I changed my registry once more.

[HKCR\sh_auto_file\shell\open\command]
@ = "C:\Users\rlcks\AppData\Local\Microsoft\WindowsApps\wt.exe" -d "%w" -p "Command Prompt" "C:\Program Files\Git\bin\bash.exe" "%L" %*

This registry work fine. But I've heard that %w value doesn't always exists and may cause critical errors.
Is it safe to use this registry?
My windows is windows 10 build 19041.508.

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
10,663 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Reza-Ameri 16,836 Reputation points
    2021-01-31T16:18:33.64+00:00

    In case you want to use bash file, it is recommended to use Windows Subsystem for Linux instead.
    It is not recommended to ingrate bash with Windows Registry directly because it is unsupported scenario and might leads to other issues.

    0 comments No comments