ALWAYS use PowerShell's native registry provider:
# Create key
$path = "Registry::HKEY_CLASSES_ROOT\Directory\shell\MyEntry"
$null = New-Item -Path $path -Force
Set-ItemProperty -Path $path -Name "(Default)" -Value "My Menu Item"
Set-ItemProperty -Path $path -Name "Icon" -Value "myapp.exe"
# Create command subkey
$null = New-Item -Path "$path\command" -Force
Set-ItemProperty -Path "$path\command" -Name "(Default)" -Value 'myapp.exe "%1"'
Before writing new registry entries, ALWAYS examine existing working examples:
# List all context menu entries
reg query "HKEY_CLASSES_ROOT\Directory\shell"
# Show specific entry with command
reg query "HKEY_CLASSES_ROOT\Directory\shell\<entry>\command"
# Full recursive dump
reg query "HKEY_CLASSES_ROOT\Directory\shell" /s
# GOOD - quotes preserved
$cmd = 'wsl.exe --cd "%1"'
# BAD - quotes may be stripped
$cmd = "wsl.exe --cd `"%1`""
Always use -LiteralPath instead of -Path for paths with special characters:
Set-Location -LiteralPath $folderPath # Handles [brackets], spaces, etc.
Create test folder:
D:\Test Folder With SpacesCreate test folder:
D:\Test[Brackets]Test BOTH right-click scenarios:
- Right-click ON the folder
- Right-click INSIDE the folder (empty space)
Verify registry entries after creation:
reg query "HKEY_CLASSES_ROOT\Directory\shell\YourEntry\command"
Common WT commands:
wt.exe -d "path" # Open at directory (uses default profile)
wt.exe -p "Profile Name" -d "path" # Specific profile
wt.exe -p "Command Prompt" -d "path" cmd /k command # CMD with command
# PowerShell script with proper parameter handling
param([string]$Path)
& wt.exe -d $Path
If batch files are required, use %~1 to strip outer quotes:
@echo off
wt.exe -d "%~1"
cmd.exe /s /k pushd "%V"
powershell.exe -NoExit -Command Set-Location -LiteralPath '%V'
wsl.exe --cd "%V"
wt.exe -d "%V" -p "Command Prompt"
"C:\Program Files\App\app.exe" "%1"
- Check if
\commandsubkey exists:reg query "...\command" - Verify quotes are preserved in the command value
- Test with a simple path first (no spaces)
- Test with a path containing spaces
- Check Windows Event Viewer for errors
- Try running the command manually in cmd/PowerShell
Converted and distributed by TomeVault — claim your Tome and manage your conversions.