Unpacking Software Livestream

Join our monthly Unpacking Software livestream to hear about the latest news, chat and opinion on packaging, software deployment and lifecycle management!

Learn More

Chocolatey Product Spotlight

Join the Chocolatey Team on our regular monthly stream where we put a spotlight on the most recent Chocolatey product releases. You'll have a chance to have your questions answered in a live Ask Me Anything format.

Learn More

Chocolatey Coding Livestream

Join us for the Chocolatey Coding Livestream, where members of our team dive into the heart of open source development by coding live on various Chocolatey projects. Tune in to witness real-time coding, ask questions, and gain insights into the world of package management. Don't miss this opportunity to engage with our team and contribute to the future of Chocolatey!

Learn More

Calling All Chocolatiers! Whipping Up Windows Automation with Chocolatey Central Management

Webinar from
Wednesday, 17 January 2024

We are delighted to announce the release of Chocolatey Central Management v0.12.0, featuring seamless Deployment Plan creation, time-saving duplications, insightful Group Details, an upgraded Dashboard, bug fixes, user interface polishing, and refined documentation. As an added bonus we'll have members of our Solutions Engineering team on-hand to dive into some interesting ways you can leverage the new features available!

Watch On-Demand
Chocolatey Community Coffee Break

Join the Chocolatey Team as we discuss all things Community, what we do, how you can get involved and answer your Chocolatey questions.

Watch The Replays
Chocolatey and Intune Overview

Webinar Replay from
Wednesday, 30 March 2022

At Chocolatey Software we strive for simple, and teaching others. Let us teach you just how simple it could be to keep your 3rd party applications updated across your devices, all with Intune!

Watch On-Demand
Chocolatey For Business. In Azure. In One Click.

Livestream from
Thursday, 9 June 2022

Join James and Josh to show you how you can get the Chocolatey For Business recommended infrastructure and workflow, created, in Azure, in around 20 minutes.

Watch On-Demand
The Future of Chocolatey CLI

Livestream from
Thursday, 04 August 2022

Join Paul and Gary to hear more about the plans for the Chocolatey CLI in the not so distant future. We'll talk about some cool new features, long term asks from Customers and Community and how you can get involved!

Watch On-Demand
Hacktoberfest Tuesdays 2022

Livestreams from
October 2022

For Hacktoberfest, Chocolatey ran a livestream every Tuesday! Re-watch Cory, James, Gary, and Rain as they share knowledge on how to contribute to open-source projects such as Chocolatey CLI.

Watch On-Demand

Downloads:

6,336

Downloads of v 0.3.3:

1,086

Last Update:

25 Jan 2024

Package Maintainer(s):

Software Author(s):

  • Miodrag Milic

Tags:

total-commander double-commander tcplugin

Total Commander Plugins Scripts

  • 1
  • 2
  • 3

0.3.3 | Updated: 25 Jan 2024

Downloads:

6,336

Downloads of v 0.3.3:

1,086

Maintainer(s):

Software Author(s):

  • Miodrag Milic

Total Commander Plugins Scripts 0.3.3

Legal Disclaimer: Neither this package nor Chocolatey Software, Inc. are affiliated with or endorsed by Miodrag Milic. The inclusion of Miodrag Milic trademark(s), if any, upon this webpage is solely to identify Miodrag Milic goods or services and not for commercial purposes.

  • 1
  • 2
  • 3

All Checks are Passing

3 Passing Tests


Validation Testing Passed


Verification Testing Passed

Details

Scan Testing Successful:

No detections found in any package files

Details
Learn More

Deployment Method: Individual Install, Upgrade, & Uninstall

To install Total Commander Plugins Scripts, run the following command from the command line or from PowerShell:

>

To upgrade Total Commander Plugins Scripts, run the following command from the command line or from PowerShell:

>

To uninstall Total Commander Plugins Scripts, run the following command from the command line or from PowerShell:

>

Deployment Method:

NOTE

This applies to both open source and commercial editions of Chocolatey.

1. Enter Your Internal Repository Url

(this should look similar to https://community.chocolatey.org/api/v2/)


2. Setup Your Environment

1. Ensure you are set for organizational deployment

Please see the organizational deployment guide

2. Get the package into your environment

  • Open Source or Commercial:
    • Proxy Repository - Create a proxy nuget repository on Nexus, Artifactory Pro, or a proxy Chocolatey repository on ProGet. Point your upstream to https://community.chocolatey.org/api/v2/. Packages cache on first access automatically. Make sure your choco clients are using your proxy repository as a source and NOT the default community repository. See source command for more information.
    • You can also just download the package and push it to a repository Download

3. Copy Your Script

choco upgrade tcps -y --source="'INTERNAL REPO URL'" [other options]

See options you can pass to upgrade.

See best practices for scripting.

Add this to a PowerShell script or use a Batch script with tools and in places where you are calling directly to Chocolatey. If you are integrating, keep in mind enhanced exit codes.

If you do use a PowerShell script, use the following to ensure bad exit codes are shown as failures:


choco upgrade tcps -y --source="'INTERNAL REPO URL'" 
$exitCode = $LASTEXITCODE

Write-Verbose "Exit code was $exitCode"
$validExitCodes = @(0, 1605, 1614, 1641, 3010)
if ($validExitCodes -contains $exitCode) {
  Exit 0
}

Exit $exitCode

- name: Install tcps
  win_chocolatey:
    name: tcps
    version: '0.3.3'
    source: INTERNAL REPO URL
    state: present

See docs at https://docs.ansible.com/ansible/latest/modules/win_chocolatey_module.html.


chocolatey_package 'tcps' do
  action    :install
  source   'INTERNAL REPO URL'
  version  '0.3.3'
end

See docs at https://docs.chef.io/resource_chocolatey_package.html.


cChocoPackageInstaller tcps
{
    Name     = "tcps"
    Version  = "0.3.3"
    Source   = "INTERNAL REPO URL"
}

Requires cChoco DSC Resource. See docs at https://github.com/chocolatey/cChoco.


package { 'tcps':
  ensure   => '0.3.3',
  provider => 'chocolatey',
  source   => 'INTERNAL REPO URL',
}

Requires Puppet Chocolatey Provider module. See docs at https://forge.puppet.com/puppetlabs/chocolatey.


4. If applicable - Chocolatey configuration/installation

See infrastructure management matrix for Chocolatey configuration elements and examples.

Package Approved

This package was approved by moderator TheCakeIsNaOH on 28 Jan 2024.

Description

TCP Scripts can be used to automate Total Commander plugin installation. Besides unpacking, scripts will setup or remove plugin for file managers that are found on the local system. Supported file managers are:

Both TC and DC are automatically detected if present on the system.

Use the following tags to browse for TC plugins on Chocolatey Community Gallery:

Use the following tags to browse custom DC/TC configuration settings:

Features

  • Supports all plugin types
  • Unpacks the plugin
  • Installs and removes plugin for Total Commander
  • Installs and removes plugin for Double Commander
  • Set TC and DC options

Notes

  • By default plugins are installed at $Env:COMMANDER_PLUGINS_PATH. If not set in the system, it defaults to $Env:ChocolateyToolsLocation\TCPlugins
  • Plugin installer will close any running instances of TC or DC prior to plugin installation
  • Plugin installer will setup up either x32 or x64 bit plugin version, but not both

Using

To use the functions, depend on this package and import tcps.ps1 like this:

$toolsPath = Split-Path $MyInvocation.MyCommand.Definition
. $Env:ChocolateyInstall\lib\tcps\tools\tcps.ps1

After that simply call Install-TCPlugin or UnInstall-TCPlugin with plugin name as a parameter and it will take care of everything. Note that you must define $toolsPath as it is used to find out embedded TC plugin path.

TCP scripts expect that TC plugin archive is embedded in the package with the file name that contains plugin name. The base file name of the plugin itself, once unpacked, must be the same as the name used within Chocolatey installation script. See code and content of existing packages for details.

For example:

  • TC plugin name : FileInfo
  • Embedded archive file name: wlx_fileinfo223.zip
  • TC Plugin name (unpacked): $Env:COMMANDER_PLUGINS_PATH\...\fileinfo.wlx[64]

Scripts totalcmd.ps1 and doublecmd.ps1 handle plugin operations for respective file managers and can be used standalone.


tools\doublecmd.ps1
# version: 1.1.9

function Set-DCCfg  {
    param(
        [ValidateSet('show', 'hide')]
        [string] $SplashForm = "hide",
        [ValidateSet('auto', 'enabled', 'disabled')]
        [string] $DarkMode = "auto"
    )

    $rootPath = Split-Path (Get-DCConfig -Path)
    $cfgPath = Join-Path $rootPath "doublecmd.cfg"

    $mapSplashForm = @{
        hide = 0
        show = -1
    }
    $mapDarkMode = @{
        auto = 1
        enabled = 2
        disabled = 3
    }

    "
SplashForm=$($mapSplashForm.$SplashForm)
DarkMode=$($mapDarkMode.$DarkMode)" | Out-File $cfgPath
}

function Test-DC() { $null -ne (Get-DCConfig -Path) }

function Set-DCAsDefaultFM($DCPath) {
    Write-Verbose "Setting Total Commander as default file manager"

    #http://doublecmd.github.io/doc/en/commandline.html
    $cmd = $DCPath + ' --no-splash -c -t "%1"'

    New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT -ea 0 | Out-Null

    Set-ItemProperty HKCR:\Drive\shell -name "(Default)" -Value "open"
    mkdir HKCR:\Drive\shell\open\command -force | Out-Null
    Set-ItemProperty HKCR:\Drive\shell\open\command  -name "(Default)" -Value $cmd

    Set-ItemProperty HKCR:\Directory\shell -name "(Default)" -Value "open"
    mkdir HKCR:\Directory\shell\open\command -force | Out-Null
    Set-ItemProperty HKCR:\Directory\shell\open\command  -name "(Default)" -Value $cmd
}


function Close-DC() {
    $doublecmd = Get-Process doublecmd -ea 0
    if (!$doublecmd) { return }
    $doublecmd | % { $_.CloseMainWindow() | Out-Null }
}

# Set a XML element via HashTable
# - Use keys ending with _ as unique id - existing elements with unique id will be removed
#
# Set-HashTable($xml, 'doublecmd.SearchTemplates', 'Template', @{Name_ = 'Executables'; FileMasks='*.exe;*.bat'} )
function Set-HashTable($Xml, [string] $Parent, [string]$Name, [HashTable[]] $Hashes ) {
    $Parent = $Parent -replace '([^.]+)\.?',"['`$1']"
    $xmlParent = iex "`$Xml$Parent"
    if (!$xmlParent) {
        throw "Non existent parent: $Parent" }

    foreach ($hash in $Hashes) {
        $idKey = ($hash.Keys | ? { $_.EndsWith('_')}) -replace '_$'
        if ($idKey) {
            $e = $xmlParent.$Name | ? { $_.$idKey -eq $hash["${idKey}_"] }
            if ($e) { $xmlParent.RemoveChild($e) | Out-Null }
        }

        $e = $xmlParent.AppendChild($Xml.CreateElement($Name))
        foreach ($k in $hash.Keys) {
            $xk = if ($k.EndsWith('_')) { $k -replace '_$' } else { $k }
            $e.AppendChild( $Xml.CreateElement($xk) ) | Out-Null
            $e.$xk = $hash.$k.ToString()
        }
    }
}

# Provide HashTable array with any legit Hotkey element
function Set-DCHotkey([HashTable[]]$Hotkeys){
    $xml_path = "$Env:AppData\doublecmd\shortcuts.scf"
    [xml] $xml = Get-Content $xml_path
    foreach ($hkey in $Hotkeys) { if (!$hkey.Form) { $hkey.Form = 'Main' } }
    Set-HashTable $xml -Parent 'doublecmd.Hotkeys.Form' -Name 'Hotkey' -Hashes $Hotkeys
    $xml.Save($xml_path)
}

function Get-DCConfig ([switch] $Path) {
    function xml_path {
        $res = "$Env:AppData\doublecmd\doublecmd.xml"
        if (Test-Path $res) {return $res}

        $res = "$Env:ProgramFiles\Double Commander\doublecmd.xml"
        if (Test-Path $res) {return $res}
    }

    $cfg_path = xml_path
    if (!$cfg_path) {
        $paths = "$Env:ProgramFiles\Double Commander", "$Env:COMMANDER_PATH", "$Env:DCOMMANDER_PATH"
        foreach ($dcInstallPath in $paths) {
            if (!$dcInstallPath) { continue }
            $exePath = Join-Path $dcInstallPath doublecmd.exe
            if (Test-Path $exePath) { break } else { $exePath = $null }
        }
        if (!$exePath) { return }

        Write-Host "Double Commander config file is not found while its executable exists"
        Write-Host "It will now be run and closed for the first time to generate config file"
        Start-Process $exePath -WindowStyle Hidden
        Start-Sleep 1
        for ($i=0; $i -lt 5; $i++) {
            $doublecmd = Get-Process doublecmd -ea 0
            if (!$doublecmd) { Start-Sleep 1; continue }

            Start-Sleep 5
            $doublecmd.CloseMainWindow() | Out-Null
            Start-Sleep 1
            break
        }
        $cfg_path = xml_path
        if (!$cfg_path) { return }
    }

    if ($Path) { return $cfg_path }
    return ([xml](Get-Content $cfg_path))
}

function Set-DCConfig( $xml ) {
    $cfg_path = Get-DCConfig -Path
    $xml.Save($cfg_path)
}

function Set-DCOptions([Parameter(ValueFromPipeline=$true)][HashTable]$Options, $UserConfig) {
    $config = if ($UserConfig) { $UserConfig } else { Close-DC; Get-DCConfig }
    if (!$config) { Write-Warning "Can't find Double Commander config, doing nothing"; return } # This prevent Gallery verifyer to fail as it runs as a user SYSTEM which has different profile path

    foreach ($section in $Options.Keys) {
        foreach ($key in $Options.$section.Keys) {
            $prefix = ''; $xmlkey = $key
            if ($key.IndexOf('.') -ne -1) {
                $prefix = $key -replace '\.[^.]+$'
                $xmlkey = $key.Replace("$prefix.",'')
                $prefix = ".$prefix"
            }

            $xml_path = "`$config.doublecmd.${section}${prefix}['$xmlkey']"
            $node = try { iex $xml_path } catch { Write-Warning "Can't set value for '$section.$key': $_"; continue }
            $val = $Options.$section.$key

            if ( $val -is [HashTable]) {
                foreach( $a in $val.Keys) {
                    $node.Attributes.Append( $config.CreateAttribute( $a ) ) | Out-Null
                    $node.$a = $val.$a.ToString()
                }
            } else {
                try { $node.InnerText = $val.ToString() } catch { Write-Warning "Can't set value for '$section.$key': $_"; }
            }
        }
    }
    if (!$UserConfig) { Set-DCConfig $config }
}

function Set-DCPlugin {
    param(
        # Full path to the one of the supported TC plugins to add to settings file
        [string] $PluginPath,

        # Lister and Content plugins: A string which determines whether plugin can handle the file or not
        # For semantics see http://java.totalcmd.net/V1.7/javadoc/plugins/wlx/WLXPluginInterface.html#listGetDetectString(int)
        [string] $DetectString,

        # Packer plugins: Space separated list of extensions to associate with this plugin
        [string] $ArchiveExt,

        # Force specific plugin type
        [string] $ForceType,

        # Set to remove plugin from settings file
        # Packer plugins: all instances will be removed
        [switch] $Uninstall
    )
    function Capitalize($s) { $s.Substring(0,1).ToUpper() + $s.Substring(1) }

    $pFile = Get-Item $PluginPath
    $pName = Capitalize $pFile.BaseName.ToString()
    $pType = if ($ForceType) { $ForceType } else { Capitalize $pFile.Extension.Substring(1).Replace('64','') }
    $archiveExts = $archiveExt -split ' '

    $config = Get-DCConfig

    $all_plugins = $config.doublecmd.Plugins."${pType}Plugins"."${pType}Plugin"
    $plugins = $all_plugins | ? { if ($pType -eq 'Wcx') { $_.Path -eq $PluginPath } else { $_.Name -eq $pName } }
    $plugins | % { $config.doublecmd.Plugins."${pType}Plugins".RemoveChild( $_ ) | Out-Null }
    if ($Uninstall)  { return Set-DCConfig $config }

    # Create XML node for plugin
    $elements = @{
        Wfx = 'Name', 'Path'
        Wcx = 'ArchiveExt', 'Path', 'Flags'
        Wlx = 'Name', 'Path', 'DetectString'
        Wdx = 'Name', 'Path', 'DetectString'
    }
    $plugin = $config.CreateElement("${pType}Plugin")
    $elements.$pType | % { $plugin.AppendChild($config.CreateElement($_)) } | Out-Null
    $plugin.Attributes.Append( $config.CreateAttribute('Enabled') ) | Out-Null

    # Set node values where they exist
    $plugin.Enabled = 'True'
    $plugin.Path = $PluginPath
    try { $plugin.Name         = $pName }        catch {}
    try { $plugin.DetectString = $DetectString } catch {}
    try { $plugin.Flags        = '31' }          catch {}

    $plugins = if ($pType -eq 'Wcx') {
        foreach ($ext in $archiveExts) { $p = $plugin.Clone(); $p.ArchiveExt = $ext; $p }
    } else { $plugin }
    $plugins | % { $config.doublecmd.Plugins["${pType}Plugins"].AppendChild( $_ ) | Out-Null }

    Set-DCConfig $config
}


# Close-DC
#Set-DCPlugin "C:\tools\TCPlugins\DiskDirExtended\DiskDirExtended.wcx64" -ArchiveExt 'list ls'
#Set-DCPlugin "C:\tools\TCPlugins\EnvVars\envvars.wfx64"
#Set-DCPlugin "C:\tools\TCPlugins\FileInfo\fileinfo.wlx64" -DetectString 'EXT="WAV" | EXT="AVI"'
# Set-DCPlugin "C:\tools\TCPlugins\Linkinfo\Linkinfo.wlx64" -DetectString 'EXT="LNK"'
#Set-DCPlugin "C:\tools\TCPlugins\ShellDetails\ShellDetails.wdx64"
# Set-DCPlugin "C:\tools\TCPlugins\Uninstaller64\Uninstaller64.wfx"
tools\Ini.ps1
function Get-IniSection([string]$Path, [string]$SectionName) { 
    [ProfileAPI]::GetSection($Path, $SectionName) 
}
function Set-IniSection([string]$Path, [string]$SectionName, [string]$Value) { 
    [ProfileAPI]::WritePrivateProfileSection($SectionName, $Value, $Path)
}
function Get-IniKey([string]$Path, [string]$SectionName, [string]$Key, [string]$Value, [string]$DefaultValue) {
    $sb = New-Object System.Text.StringBuilder(256)
    [ProfileApi]::GetPrivateProfileString($SectionName, $Key, $DefaultValue, $sb, $sb.Capacity, $Path) | Out-Null
    $sb.ToString()
}
function Set-IniKey([string]$Path, [string]$SectionName, $Key, $Value) {
    if ($null -eq $Value) { $Value = [NullString]::Value }
    if ($null -eq $Key)   { $Key   = [NullString]::Value }
    [ProfileApi]::WritePrivateProfileString($SectionName, $Key, $Value, $Path) 
}
if ("ProfileApi" -as [type]) { return }

Add-Type @'
using System; 
using System.Collections.Generic; 
using System.Text; 
using System.Runtime.InteropServices; 

public class ProfileAPI { 

    [DllImport("kernel32.dll")] 
    public static extern bool WritePrivateProfileSection( 
        string lpAppName, 
        string lpString,
        string lpFileName
    ); 

    [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)] 
    [return: MarshalAs(UnmanagedType.Bool)] 
    public static extern bool WritePrivateProfileString( 
        string lpAppName, 
        string lpKeyName, 
        string lpString, 
        string lpFileName);
     
    [DllImport("kernel32.dll", CharSet = CharSet.Ansi, SetLastError = true)] 
    public static extern uint GetPrivateProfileSectionNames(
        IntPtr lpReturnedString, 
        uint nSize, 
        string lpFileName); 
     
    [DllImport("kernel32.dll", CharSet = CharSet.Ansi, SetLastError = true)] 
    static extern uint GetPrivateProfileSection(
        string lpAppName, 
        IntPtr lpReturnedString, 
        uint nSize, 
        string lpFileName); 
     
    [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)] 
    public static extern uint GetPrivateProfileString( 
        string lpAppName, 
        string lpKeyName, 
        string lpDefault, 
        StringBuilder lpReturnedString, 
        uint nSize, 
        string lpFileName); 
    
    public static string[] GetSectionNames(string iniFile) { 
        uint MAX_BUFFER = 32767; 
        IntPtr pReturnedString = Marshal.AllocCoTaskMem((int)MAX_BUFFER); 
        uint bytesReturned = GetPrivateProfileSectionNames(pReturnedString, MAX_BUFFER, iniFile); 
        if (bytesReturned == 0) { 
            Marshal.FreeCoTaskMem(pReturnedString); 
            return null; 
        } 
        string local = Marshal.PtrToStringAnsi(pReturnedString, (int)bytesReturned).ToString(); 
        char[] c = new char[1]; 
        c[0] = '\x0'; 
        return local.Split(c, System.StringSplitOptions.RemoveEmptyEntries);
        
        //Marshal.FreeCoTaskMem(pReturnedString); 
        //use of Substring below removes terminating null for split 
        //char[] c = local.ToCharArray(); 
        //return MultistringToStringArray(ref c); 
        //return c; 
        //return local; //.Substring(0, local.Length - 1).Split('\0'); 
    } 
     
    public static string[] GetSection(string iniFilePath, string sectionName) { 
        uint MAX_BUFFER = 32767; 
        IntPtr pReturnedString = Marshal.AllocCoTaskMem((int)MAX_BUFFER); 
        uint bytesReturned = GetPrivateProfileSection(sectionName, pReturnedString, MAX_BUFFER, iniFilePath); 
        if (bytesReturned == 0) { 
            Marshal.FreeCoTaskMem(pReturnedString); 
            return null; 
        } 
        string local = Marshal.PtrToStringAnsi(pReturnedString, (int)bytesReturned).ToString(); 
        char[] c = new char[1] { '\x0' }; 
        return local.Split(c, System.StringSplitOptions.RemoveEmptyEntries); 
    } 
     
} 
'@
tools\tcps.ps1
. $PSScriptRoot\doublecmd.ps1
. $PSScriptRoot\totalcmd.ps1

if (!$Env:COMMANDER_PLUGINS_PATH) { $Env:COMMANDER_PLUGINS_PATH = Join-Path (Get-ToolsLocation) TCPlugins }
mkdir -ea 0 $Env:COMMANDER_PLUGINS_PATH

$TCP_Types = 'Wcx', 'Wdx', 'Wfx', 'Wlx'

function Get-TCPluginPath {
    param(
        [string] $Name,
        [string] $PluginsPath = $Env:COMMANDER_PLUGINS_PATH
    )
    $is32 = if ((Get-ProcessorBits 32) -or $env:chocolateyForceX86 -eq 'true') { $true } else { $false }

    $pluginExtensions = $TCP_Types | % { if ($is32) {"*.$_"} else {"*.${_}64"} }
    $pluginFile = Get-ChildItem -Recurse -Path $PluginsPath -Include $pluginExtensions -Filter "$Name.*" 
    if (!$pluginFile) { throw "Can't find plugin installation for the '$Name'" }
    if ($pluginFile.Count -gt 1) { throw "Multiple plugins found by the name '$Name': $($pluginFile.Name)"  }
    return $pluginFile.FullName
}

function Expand-TCPlugin([string] $Name, [string]$SourcePath = $toolsPath, [string]$DestinationPath = $Env:COMMANDER_PLUGINS_PATH) {
    $packageArgs = @{
        PackageName    = $Env:ChocolateyPackageName 
        FileFullPath   = Get-Item $SourcePath\*$Name* -Include '*.rar','*.zip','*.7z'
        FileFullPath64 = Get-Item $SourcePath\*$Name* -Include '*.rar','*.zip','*.7z'
        Destination    = "$DestinationPath\$Name"
    }
    Get-ChocolateyUnzip @packageArgs
    Remove-Item $packageArgs.FileFullPath -ea 0
}

function Install-TCPlugin([string]$Name, [string]$DetectString, [string]$ArchiveExt, [switch]$NoExpand, [string] $ForceType ) { 
    Close-DC; Close-TC

    if (!$NoExpand) { Expand-TCPlugin $Name }

    $pluginPath = Get-TCPluginPath $Name
    if (Test-DC) {
        Write-Host "Adding plugin settings for Double Commander"
        Set-DCPlugin $pluginPath -DetectString $DetectString -ArchiveExt $ArchiveExt -ForceType $ForceType
    }
    if (Test-TC) {
        Write-Host "Adding plugin settings for Total Commander"
        Set-TCPlugin $pluginPath -DetectString $DetectString -ArchiveExt $ArchiveExt -ForceType $ForceType
    }
}

function Uninstall-TCPlugin([string]$Name, [string]$DestinationPath=$Env:COMMANDER_PLUGINS_PATH, [string]$ForceType, [switch]$NoRemove) {
    Close-DC; Close-TC

    $pluginPath = Get-TCPluginPath $Name
    if (Test-DC) {
        Write-Host "Removing plugin settings for Double Commander"
        Set-DCPlugin $pluginPath -Uninstall -ForceType $ForceType
    }
    if (Test-TC) {
        Write-Host "Removing plugin settings for Total Commander"
        Set-TCPlugin $pluginPath -Uninstall -ForceType $ForceType
    }

    if (!$NoRemove) {
        Write-Host "Removing plugin files: $DestinationPath\$Name"
        Remove-Item $DestinationPath\$Name -Recurse
    }
}

# $Name = 'DiskDirExtended'

# import-module C:\ProgramData\chocolatey\helpers\chocolateyInstaller.psm1
# $toolsPath = Resolve-Path $PSScriptRoot\..\..\tcp-$Name\tools
# $Env:COMMANDER_INI = ''
# $Env:COMMANDER_PLUGINS_PATH = Resolve-Path "$Env:ChocolateyToolsLocation\TCPlugins"
# Install-TCPlugin $Name -ArchiveExt 'list'
tools\totalcmd.ps1
. $PSScriptRoot\ini.ps1

function Set-TCAsDefaultFM($TCPath) {
    Write-Verbose "Setting Total Commander as default file manager"

    New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT -ea 0 | Out-Null

    Set-ItemProperty HKCR:\Drive\shell -name "(Default)" -Value "open"
    mkdir HKCR:\Drive\shell\open\command -force | Out-Null
    Set-ItemProperty HKCR:\Drive\shell\open\command  -name "(Default)" -Value "$TCPath /O ""%1"""

    Set-ItemProperty HKCR:\Directory\shell -name "(Default)" -Value "open"
    mkdir HKCR:\Directory\shell\open\command -force | Out-Null
    Set-ItemProperty HKCR:\Directory\shell\open\command  -name "(Default)" -Value "$TCPath /O ""%1"""
}

function Test-TC { $null -ne (Get-TCConfig -Path) }

function Close-TC() {
    $totalcmd = Get-Process totalcmd* -ea 0
    if (!$totalcmd) { return }
    $totalcmd | % { $_.CloseMainWindow() | Out-Null }
}

function Set-TCTemplates( [HashTable[]] $Templates ) {
    $o = @{ searches = @{}; colors = @{} }
    foreach($template in $Templates) {
        $name = $template.Name
        $o.searches."${name}_SearchFor"   = $template.FilesMasks
        $o.searches."${name}_SearchIn"    = $template.StartPath
        $o.searches."${name}_SearchText"  = ''
        $o.searches."${name}_SearchFlags" = ''
    }
    Set-TCOptions $o

    # Clear ALL existing colors
    $configPath = Get-TCConfig -Path
    $iniSection = Get-IniSection $configPath 'Colors'
    [array] $filters = $iniSection | ? { $_ -match "ColorFilter\d+=" }
    for ($i=1; $i -le $filters.Count; $i++)  { 
        Set-IniKey $configPath 'Colors' "ColorFilter${i}" | Out-Null
        Set-IniKey $configPath 'Colors' "ColorFilter${i}Color" | Out-Null
    }

    foreach($template in $Templates){
        if (!$template.Color) { continue }
        $j++
        Set-IniKey $configPath 'Colors' "ColorFilter${j}" (">" + $template.Name) | Out-Null
        Set-IniKey $configPath 'Colors' "ColorFilter${j}Color" $template.Color   | Out-Null
    }
}

function Get-TCInstallPath {
    function check($path) { (gi $path\totalcmd.exe -ea 0).VersionInfo.InternalName -eq 'TOTALCMD' }
    
    $res = $Env:COMMANDER_PATH
    if ( check $res ) { return $res }

    $res = (gp 'HKCU:\Software\Ghisler\Total Commander' -ea 0).InstallDir
    if ( check $res ) { return $res }

    $res = (gp 'HKLM:\Software\Ghisler\Total Commander' -ea 0).InstallDir
    if ( check $res ) { return $res }
}

function Set-TCOptions([Parameter(ValueFromPipeline=$true)][HashTable]$Options) {
    $configPath = Get-TCConfig -Path
    if (!$configPath) { throw 'Total Commander config file not found' }
    foreach ($section in $Options.Keys) {        
        foreach ( $key in $Options.$section.Keys ) { 
            Set-IniKey $configPath $section $key $Options.$section.$key | Out-Null
        }
    }
}

function Get-TCConfig( [switch] $Path ) {
    function ini_path {
        # $res = $Env:COMMANDER_INI
        # if ( $res -and (Test-Path $res)) { return $res }

        $res = (gp 'HKCU:\Software\Ghisler\Total Commander' -ea 0).IniFileName
        if ( $res -and (Test-Path $res)) { return $res }

        $res = (gp 'HKLM:\Software\Ghisler\Total Commander' -ea 0).IniFileName
        if ( $res -and (Test-Path $res)) { return $res }

        $res = "$Env:AppData\Ghisler\wincmd.ini"
        if ( $res -and (Test-Path $res)) { return $res }

        $res = "$Env:WinDir\wincmd.ini"
        if ( $res -and (Test-Path $res)) { return $res }
    }

    $cfg_path = ini_path
    if (!$cfg_path) { return }

    if ($Path) { return $cfg_path }
    return (Get-Content $cfg_path -Encoding UTF8 -Raw )
}

function Set-TCPlugin {
    param(
        # Full path to the one of the supported TC plugins to add to settings file
        [string] $PluginPath,
        
        # Lister and Content plugins: A string which determines whether plugin can handle the file or not
        # For semantics see http://java.totalcmd.net/V1.7/javadoc/plugins/wlx/WLXPluginInterface.html#listGetDetectString(int)
        [string] $DetectString,
        
        # Packer plugins: Space separated list of extensions to associate with this plugin
        [string] $ArchiveExt,

        # Force specific plugin type
        [string] $ForceType,
        
        # Set to remove plugin from settings file
        # Packer plugins: all instances will be removed
        [switch] $Uninstall
    )  
    function Capitalize($s) { $s.Substring(0,1).ToUpper() + $s.Substring(1) }
    
    $pFile = Get-Item $PluginPath
    $pName = Capitalize $pFile.BaseName.ToString()
    $pType = if ($ForceType) { $ForceType } else { Capitalize $pFile.Extension.Substring(1).Replace('64','') }
    $archiveExts = $archiveExt -split ' '
    
    $configPath = Get-TCConfig -Path
    $sectionName = @{Wlx='ListerPlugins'; Wfx='FileSystemPlugins'; Wdx='ContentPlugins'; Wcx='PackerPlugins'}.$pType
    
    if ($Uninstall) {
        switch ($pType) {
            {$_ -in 'Wcx','Wlx','Wdx' } {       
                $iniSection = Get-IniSection $configPath $sectionName
                $iniSection | sls $PluginPath -SimpleMatch  | % {
                    $key = $_ -split "=",2 | select -first 1
                    Set-IniKey $configPath $sectionName $key | Out-Null
                    if ($_ -in 'Wlx','Wdx') { Set-IniKey $configPath $sectionName ${key}_detect | Out-Null }
                }
                if ($_ -in 'Wlx','Wdx') {
                    # Reorder other keys once a plugin is removed
                    $iniSection = Get-IniSection $configPath $sectionName | sort
                    $s = @(); $j=0
                    for ($i=0; $i -lt $iniSection.Count; $i++) {
                        $key, $val = $iniSection[$i] -split "=", 2
                        $key = $key.Trim()
                        if ($key -like '*_detect') {                            
                            $lastkey = $j++
                            $s += "$($lastkey)_detect=$val"
                        }  elseif ($key -match '\d+') {
                            $s += "$lastkey=$val"
                        }
                    }
                    $s = $s -join "`n"
                    Set-IniSection $configPath $sectionName $s | Out-Null
                }
            }
            'Wfx' {
                Set-IniKey $configPath $sectionName     $pName | Out-Null
                Set-IniKey $configPath ${sectionName}64 $pName | Out-Null
            }
        }
        return
    }

    switch ($pType) {
        'Wcx' {
            foreach ($ext in $archiveExts) { Set-IniKey $configPath $sectionName $ext $PluginPath | Out-Null }
        }
        {$_ -in 'Wdx','Wlx' } {
            $iniSection = Get-IniSection $configPath $sectionName
            $iniSection | sls $PluginPath -SimpleMatch  | % {
                $key = $_ -split "=",2 | select -first 1
                Set-IniKey $configPath $sectionName $key | Out-Null
                Set-IniKey $configPath $sectionName ${key}_detect | Out-Null
            }

            $iniSection = Get-IniSection $configPath $sectionName                 
            $cnt = $iniSection | % { $_ -split '=' | select -first 1 } | sort | select -last 1
            $cnt = if ($cnt) { 1+($cnt -replace '_.+') } else { 0 }
            $cnt = $cnt.ToString()
            Set-IniKey $configPath $sectionName $cnt $PluginPath | Out-Null
            if ($DetectString) { Set-IniKey $configPath $sectionName ${cnt}_detect $DetectString | Out-Null }
        }
        'Wfx' {
            Set-IniKey $configPath $sectionName $pName $PluginPath | Out-Null
        }        
    }
}

#Close-TC
#Set-TCPlugin "C:\tools\TCPlugins\DiskDirExtended\DiskDirExtended.wcx64" -ArchiveExt 'list ls'
#Set-TCPlugin "C:\tools\TCPlugins\EnvVars\envvars.wfx64"
#Set-TCPlugin "C:\tools\TCPlugins\ShellDetails\ShellDetails.wdx64"
#Set-TCPlugin "C:\tools\TCPlugins\LinkInfo\LinkInfo.wlx64" -DetectString 'EXT="LNK"'

Log in or click on link to see number of positives.

In cases where actual malware is found, the packages are subject to removal. Software sometimes has false positives. Moderators do not necessarily validate the safety of the underlying software, only that a package retrieves software from the official distribution point and/or validate embedded software against official distribution point (where distribution rights allow redistribution).

Chocolatey Pro provides runtime protection from possible malware.

Add to Builder Version Downloads Last Updated Status
Total Commander Plugins Scripts 0.3.2 2647 Monday, June 6, 2022 Approved
Total Commander Plugins Scripts 0.3.1 565 Saturday, January 22, 2022 Approved
Total Commander Plugins Scripts 0.3 1944 Monday, October 14, 2019 Approved

This package has no dependencies.

Discussion for the Total Commander Plugins Scripts Package

Ground Rules:

  • This discussion is only about Total Commander Plugins Scripts and the Total Commander Plugins Scripts package. If you have feedback for Chocolatey, please contact the Google Group.
  • This discussion will carry over multiple versions. If you have a comment about a particular version, please note that in your comments.
  • The maintainers of this Chocolatey Package will be notified about new comments that are posted to this Disqus thread, however, it is NOT a guarantee that you will get a response. If you do not hear back from the maintainers after posting a message below, please follow up by using the link on the left side of this page or follow this link to contact maintainers. If you still hear nothing back, please follow the package triage process.
  • Tell us what you love about the package or Total Commander Plugins Scripts, or tell us what needs improvement.
  • Share your experiences with the package, or extra configuration or gotchas that you've found.
  • If you use a url, the comment will be flagged for moderation until you've been whitelisted. Disqus moderated comments are approved on a weekly schedule if not sooner. It could take between 1-5 days for your comment to show up.
comments powered by Disqus