Skip to content

Instantly share code, notes, and snippets.

@ElJefeDSecurIT
Created February 11, 2020 07:07
Show Gist options
  • Save ElJefeDSecurIT/b8de7f3852e4458c1935d1e1af399966 to your computer and use it in GitHub Desktop.
Save ElJefeDSecurIT/b8de7f3852e4458c1935d1e1af399966 to your computer and use it in GitHub Desktop.
WSLHere
## in case you want to have a wslHere dropdown in Windows:
$null = 0..1 | % {
$key = New-Item -Force $('HKCU:\Software\Classes\Directory{0}\shell\WSLHere' -f ('', '\Background')[$_])
$key | New-ItemProperty -Name '(Default)' -Value 'WSL Here' -Type String
$key | New-ItemProperty -Name 'Icon' -Value '%LOCALAPPDATA%\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\usr\share\wslu\wsl.ico' -Type ExpandString
$key = New-Item -Force "$($key.PsPath)\command"
$key | New-ItemProperty -Name '(Default)' -Value "cmd /c cd `"$(('%1', '%V')[$_])`" && wsl.exe" -Type String
}
## ## to remove the above.
## 0..1 | % {
## Remove-Item -Recurse -LiteralPath $('HKCU:\Software\Classes\Directory{0}\shell\WSLHere' -f ('', '\Background')[$_])
## }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment