ネットワークドライブを Z:\ 辺りにぶら下げて、Z:\ の background で WSL from here すると以下のように言われて失敗する。
パラメータとしては、Z:\ の background を開くと
エラーメッセージの 2 行目を見るとダブルクオーテーションが3つあるので、Z:\ 直後のダブルクオーテーションがエスケープされて
['%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe' の起動時にエラー 2147942667 (0x8007010b) が発生しました] 先頭のディレクトリ "Z:" -p Ubuntu" にアクセスできませんでしたレジストリの設定としては以下。
- HKCR\Directory\Background\shell\WSLUbuntuHere\command
- @="%LOCALAPPDATA%\Microsoft\WindowsApps\wt.exe" -d "%V" -p Ubuntu
パラメータとしては、Z:\ の background を開くと
%0=["C:\Users\kou\AppData\Local\Microsoft\WindowsApps\wt.exe"] %1=[-d] %2=["Z:\"] %3=[-p] %4=[Ubuntu]Desktop の background を開くと
%0=["C:\Users\kou\AppData\Local\Microsoft\WindowsApps\wt.exe"] %1=[-d] %2=["C:\Users\kou\Desktop"] %3=[-p] %4=[Ubuntu]が渡る。
エラーメッセージの 2 行目を見るとダブルクオーテーションが3つあるので、Z:\ 直後のダブルクオーテーションがエスケープされて
C:\Users\kou\AppData\Local\Microsoft\WindowsApps\wt.exe -d 'Z:" -p Ubuntu'のように解釈されているらしく、PowerShell からこれを実行すると結果が一致する。
Cygwin の chere はどうしてんのよ?と思い、cmd について調べてみると以下の通りだった。
試しに PowerShell から以下のように設定してみると実にうまく動いてくれた。
なお、Folder でも Z:\ を食わせると同じことが起こる。
これは Directory は Z:\ に紐づかないので、Folder の設定を Directory に移して、別途 Z:\ 用の設定をダブルクオーテーションなしで Drive に
ふと、NoWorkingDirectory なるパラメータに気付く。
あれ?これ、cd 済みなのって、NoWorkingDirectory って値を作ってないからでは?
と気付き、全部 -d . で良いのでは?と一瞬思ったのだが、Folder だと WorkingDirectory が親になるので駄目だった。
まとめると以下のようになった。
$ chere -icmp -t cmd -s cmd regtool -w add /HKCU/Software/Classes/Drive/Shell/cygwin64_cmd regtool -w -s set /HKCU/Software/Classes/Drive/Shell/cygwin64_cmd/ "&Command Prompt Here" regtool -w add /HKCU/Software/Classes/Drive/Shell/cygwin64_cmd/command regtool -w -e set /HKCU/Software/Classes/Drive/Shell/cygwin64_cmd/command/ "cmd.exe /k cd /d \"%L\"" regtool -w add /HKCU/Software/Classes/Directory/Shell/cygwin64_cmd regtool -w -s set /HKCU/Software/Classes/Directory/Shell/cygwin64_cmd/ "&Command Prompt Here" regtool -w add /HKCU/Software/Classes/Directory/Shell/cygwin64_cmd/command regtool -w -e set /HKCU/Software/Classes/Directory/Shell/cygwin64_cmd/command/ "cmd.exe /k cd /d \"%L\"" regtool -w add /HKCU/Software/Classes/Drive/Background/Shell/cygwin64_cmd regtool -w -s set /HKCU/Software/Classes/Drive/Background/Shell/cygwin64_cmd/ "&Command Prompt Here" regtool -w add /HKCU/Software/Classes/Drive/Background/Shell/cygwin64_cmd/command regtool -w -e set /HKCU/Software/Classes/Drive/Background/Shell/cygwin64_cmd/command/ "cmd.exe " regtool -w add /HKCU/Software/Classes/Directory/Background/Shell/cygwin64_cmd regtool -w -s set /HKCU/Software/Classes/Directory/Background/Shell/cygwin64_cmd/ "&Command Prompt Here" regtool -w add /HKCU/Software/Classes/Directory/Background/Shell/cygwin64_cmd/command regtool -w -e set /HKCU/Software/Classes/Directory/Background/Shell/cygwin64_cmd/command/ "cmd.exe "なんと background はディレクトリ指定を行ってない。つまり、cd 済みって事?
試しに PowerShell から以下のように設定してみると実にうまく動いてくれた。
REG ADD HKCR\Directory\Background\Shell\WSLUbuntuHere\command /f /ve /t REG_EXPAND_SZ /d '"""%LOCALAPPDATA%\Microsoft\WindowsApps\wt.exe""" -d . -p Ubuntu'
なお、Folder でも Z:\ を食わせると同じことが起こる。
これは Directory は Z:\ に紐づかないので、Folder の設定を Directory に移して、別途 Z:\ 用の設定をダブルクオーテーションなしで Drive に
REG ADD HKCR\Drive\Shell\WSLUbuntuHere\command /f /ve /t REG_EXPAND_SZ /d '"""%LOCALAPPDATA%\Microsoft\WindowsApps\wt.exe""" -d %L -p Ubuntu'みたいに行うと回避出来たのだが、
ふと、NoWorkingDirectory なるパラメータに気付く。
あれ?これ、cd 済みなのって、NoWorkingDirectory って値を作ってないからでは?
と気付き、全部 -d . で良いのでは?と一瞬思ったのだが、Folder だと WorkingDirectory が親になるので駄目だった。
まとめると以下のようになった。
# For PowerShell REG ADD HKCR\Drive\Shell\WSLUbuntuHere /f /ve /d "WSL Ubuntu here" REG ADD HKCR\Drive\Shell\WSLUbuntuHere /f /v Icon /t REG_EXPAND_SZ /d '"""%ProgramFiles%\WindowsApps\CanonicalGroupLimited.UbuntuonWindows_2004.2022.1.0_x64__79rhkp1fndgsc\ubuntu.exe"""' REG ADD HKCR\Drive\Shell\WSLUbuntuHere\command /f /ve /t REG_EXPAND_SZ /d '"""%LOCALAPPDATA%\Microsoft\WindowsApps\wt.exe""" -d %L -p Ubuntu' REG ADD HKCR\Directory\Shell\WSLUbuntuHere /f /ve /d "WSL Ubuntu here" REG ADD HKCR\Directory\Shell\WSLUbuntuHere /f /v Icon /t REG_EXPAND_SZ /d '"""%ProgramFiles%\WindowsApps\CanonicalGroupLimited.UbuntuonWindows_2004.2022.1.0_x64__79rhkp1fndgsc\ubuntu.exe"""' REG ADD HKCR\Directory\Shell\WSLUbuntuHere\command /f /ve /t REG_EXPAND_SZ /d '"""%LOCALAPPDATA%\Microsoft\WindowsApps\wt.exe""" -d """%L""" -p Ubuntu' REG ADD HKCR\Directory\Background\Shell\WSLUbuntuHere /f /ve /d "WSL Ubuntu here" REG ADD HKCR\Directory\Background\Shell\WSLUbuntuHere /f /v Icon /t REG_EXPAND_SZ /d '"""%ProgramFiles%\WindowsApps\CanonicalGroupLimited.UbuntuonWindows_2004.2022.1.0_x64__79rhkp1fndgsc\ubuntu.exe"""' REG ADD HKCR\Directory\Background\Shell\WSLUbuntuHere\command /f /ve /t REG_EXPAND_SZ /d '"""%LOCALAPPDATA%\Microsoft\WindowsApps\wt.exe""" -d . -p Ubuntu'削除は以下
REG DELETE HKCR\Folder\Shell\WSLUbuntuHere /f REG DELETE HKCR\Drive\Shell\WSLUbuntuHere /f REG DELETE HKCR\Directory\Shell\WSLUbuntuHere /f REG DELETE HKCR\Directory\Background\Shell\WSLUbuntuHere /f
タグ
コメントをかく