11<# CalibreImportShellExtension Setup file.
2- This script registers all DLL files in the directory as context menu handlers for various file extensions.
2+ This script registers all CalibreImport Shell Extension DLL files;
3+ Registration creates context menu handlers for Calibre file extensions.
34 The script can be run with the following arguments:
45 -i: Register the DLLs and add registry entries.
56 -u: Unregister the DLLs and remove registry entries.
@@ -13,6 +14,7 @@ param (
1314 [switch ]$re
1415)
1516
17+ # variables
1618$scriptPath = $MyInvocation.MyCommand.Path
1719$scriptDir = Split-Path - Parent $scriptPath
1820$logFilePath = Join-Path $scriptDir " SetupLog.txt"
@@ -63,6 +65,7 @@ function Unregister-Dll {
6365 }
6466}
6567
68+ # full list of Calibre-supported extensions from the registry
6669function GetCalibreExtensions {
6770 $calibreAssocKey = " HKCU:\SOFTWARE\calibre\calibre64bit\Capabilities\FileAssociations"
6871 if (Test-Path $calibreAssocKey ) {
@@ -74,6 +77,8 @@ function GetCalibreExtensions {
7477 }
7578}
7679
80+ <# adding registry entries for all Calibre-supported extensions
81+ this is redundant, since the C# code already takes care of this upon registration #>
7782function Add-RegistryEntries {
7883 $extensions = GetCalibreExtensions
7984 $guid = " 8E5CD5CA-64E0-479A-B62F-B1FC00FF0227"
@@ -88,6 +93,8 @@ function Add-RegistryEntries {
8893 }
8994}
9095
96+ <# removing registry entries for all Calibre-supported extensions
97+ this is redundant, since the C# code already takes care of this upon unregistration #>
9198function Remove-RegistryEntries {
9299 $extensions = GetCalibreExtensions
93100
@@ -100,12 +107,14 @@ function Remove-RegistryEntries {
100107 }
101108}
102109
110+ # optional
103111function Restart-Explorer {
104112 Stop-Process - Name explorer - Force
105113 Start-Process explorer
106114 Log " Explorer restarted"
107115}
108116
117+ # verify whether the dll registration went through successfully
109118function Check-DllRegistration {
110119 param (
111120 [string ]$dllPath
@@ -133,6 +142,7 @@ if (-not $dllFiles) {
133142 throw " No DLLs found in the script directory."
134143}
135144
145+ # main script logic
136146if ($i -or (-not $u -and -not $re )) {
137147 foreach ($dllFile in $dllFiles ) {
138148 $dllPath = $dllFile.FullName
0 commit comments