Skip to content

Instantly share code, notes, and snippets.

@jcberquist
Created January 26, 2021 17:00
Show Gist options
  • Save jcberquist/4fd7a73b0eb9a925c810f2a1444f2290 to your computer and use it in GitHub Desktop.
Save jcberquist/4fd7a73b0eb9a925c810f2a1444f2290 to your computer and use it in GitHub Desktop.
$Item = Get-Content $args[0] | ConvertFrom-Json
New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
$Item.locations | ForEach-Object {
Write-Output ($_.path + "\" + $Item.key)
if (Test-Path -LiteralPath ($_.path + "\" + $Item.key)) {
Remove-Item -LiteralPath ($_.path + "\" + $Item.key) -Recurse
}
Push-Location -LiteralPath $_.path
New-Item -Name $Item.key -Value $_.text
New-ItemProperty -Path $Item.key -Name "Icon" -Value $Item.icon
New-Item -Name ($Item.key + "\command") -Value ($Item.executable + " `"" + $_.target + "`"")
Pop-Location
}
Remove-PSDrive -Name HKCR
{
"executable": "C:\\Program Files\\Sublime Merge\\sublime_merge.exe",
"icon": "C:\\Program Files\\Sublime Merge\\sublime_merge.exe",
"key": "Sublime Merge",
"locations": [
{
"path": "HKCR:\\Directory\\shell",
"target": "%1",
"text": "Open with Sublime Merge"
},
{
"path": "HKCR:\\Directory\\Background\\shell",
"target": "%V",
"text": "Open Sublime Merge here"
}
]
}
{
"executable": "C:\\Program Files\\Sublime Text\\sublime_text.exe",
"icon": "C:\\Program Files\\Sublime Text\\sublime_text.exe",
"key": "Sublime Text",
"locations": [
{
"path": "HKCR:\\*\\shell",
"target": "%1",
"text": "Open with Sublime Text"
},
{
"path": "HKCR:\\Directory\\shell",
"target": "%1",
"text": "Open with Sublime Text"
},
{
"path": "HKCR:\\Directory\\Background\\shell",
"target": "%V",
"text": "Open Sublime Text here"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment