Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register cmder in the context menu from powershell #962

Merged
merged 4 commits into from
May 24, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions scripts/utils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,39 @@ function Register-Cmder(){
)
Begin
{
New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT > $null
}
Process
{
New-Item -Path "HKCR:\Directory\Shell\Cmder" -Force -Value $MenuText
New-Item -Path "HKCR:\Directory\Shell\Cmder" -Force -Value $MenuText
New-ItemProperty -Path "HKCR:\Directory\Shell\Cmder" -Force -Name "Icon" -Value `"$icon`"
New-ItemProperty -Path "HKCR:\Directory\Shell\Cmder" -Force -Name "NoWorkingDirectory"
New-Item -Path "HKCR:\Directory\Shell\Cmder\Command" -Force -Value "`"$PathToExe`" `"$Command`" "
New-Item -Path "HKCR:\Directory\Shell\Cmder\Command" -Force -Value "`"$PathToExe`" `"$Command`" "

New-Item -Path "HKCR:\Directory\Background\Shell\Cmder" -Force -Value $MenuText
New-ItemProperty -Path "HKCR:\Directory\Background\Shell\Cmder" -Force -Name "Icon" -Value `"$icon`"
New-ItemProperty -Path "HKCR:\Directory\Background\Shell\Cmder" -Force -Name "NoWorkingDirectory"
New-Item -Path "HKCR:\Directory\Background\Shell\Cmder\Command" -Force -Value "`"$PathToExe`" `"$Command`" "
}
End
{
Remove-PSDrive -Name HKCR
}
}

function Unregister-Cmder{
Begin
{
New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT > $null
}
Process
{
Remove-Item -Path "HKCR:\Directory\Shell\Cmder" -Recurse
Remove-Item -Path "HKCR:\Directory\Background\Shell\Cmder" -Recurse
}
End
{
Remove-PSDrive -Name HKCR
}
}

Expand Down