From 67de97a492c9389f95499db38f9474a1c20ec585 Mon Sep 17 00:00:00 2001 From: Jackbennett Date: Tue, 24 May 2016 15:43:25 +0100 Subject: [PATCH 1/4] Indent parameters for Path clarity --- scripts/utils.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/utils.ps1 b/scripts/utils.ps1 index 548eef2..cf33725 100644 --- a/scripts/utils.ps1 +++ b/scripts/utils.ps1 @@ -83,10 +83,10 @@ function Register-Cmder(){ } 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`" " } } From 49cc35bccfb9431942f65c739c894c1b8fe5505f Mon Sep 17 00:00:00 2001 From: Jackbennett Date: Tue, 24 May 2016 15:44:54 +0100 Subject: [PATCH 2/4] Add unregister function, Add 'Background' Registry keys Adding the registry keys that match the c++ code in the cmder.exe call /REGISTER ALL and /UNREGISTER ALL. USER is untested. --- scripts/utils.ps1 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/scripts/utils.ps1 b/scripts/utils.ps1 index cf33725..ead3064 100644 --- a/scripts/utils.ps1 +++ b/scripts/utils.ps1 @@ -87,6 +87,23 @@ function Register-Cmder(){ 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\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`" " + } +} + +function Unregister-Cmder{ + Begin + { + New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT + } + Process + { + Remove-Item -Path "HKCR:\Directory\Shell\Cmder" -Recurse + Remove-Item -Path "HKCR:\Directory\Background\Shell\Cmder" -Recurse } } From 2d812f1d02b9db2a304bd9bdcf478c4c287d3f43 Mon Sep 17 00:00:00 2001 From: Jackbennett Date: Tue, 24 May 2016 15:49:30 +0100 Subject: [PATCH 3/4] Quiet the function output of useless information --- scripts/utils.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/utils.ps1 b/scripts/utils.ps1 index ead3064..f6dde41 100644 --- a/scripts/utils.ps1 +++ b/scripts/utils.ps1 @@ -79,7 +79,7 @@ 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 { @@ -98,7 +98,7 @@ function Register-Cmder(){ function Unregister-Cmder{ Begin { - New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT + New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT > $null } Process { From a07062d10dc73508cfad709044751add84753ab1 Mon Sep 17 00:00:00 2001 From: Jackbennett Date: Tue, 24 May 2016 15:50:43 +0100 Subject: [PATCH 4/4] Remove the Registry hive after making the changes --- scripts/utils.ps1 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/utils.ps1 b/scripts/utils.ps1 index f6dde41..d1f932a 100644 --- a/scripts/utils.ps1 +++ b/scripts/utils.ps1 @@ -93,6 +93,10 @@ function Register-Cmder(){ 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{ @@ -105,6 +109,10 @@ function Unregister-Cmder{ Remove-Item -Path "HKCR:\Directory\Shell\Cmder" -Recurse Remove-Item -Path "HKCR:\Directory\Background\Shell\Cmder" -Recurse } + End + { + Remove-PSDrive -Name HKCR + } } function Download-File {