blog how-to

Extending Total Commander

Over the years, I’ve used the file manager in a number of different and novel ways. With every new update, the tool gets better and better. In parallel, I wrap a number of things around my copy of Total Commander to make it truly useful on machines I work with and operate. These details are mainly for use on 64-bit versions of windows, but with some alterations, all of this works on 32-bit if you support that.

Packaging the installer

To build, save, and update Total Commander, I needed a way to build all the tools and modifications I wanted in a lean, understated but maximally useful package. To achieve this, I use the incredibly useful NSIS and the rarer NSIS 64-bit compiled edition (download). This tool allows me to build the full Total Commander install with utilities and provides an uninstaller for quick removal.

At the start of the install process, I kill all running Total Commander instances. I previously used tools such as my own Prockill and ProcessHacker, but these tools didn’t always avoid Antivirus false positives. So, I looked for an internal Windows tool that could do it and found taskkill worked. This is the NSIS code to do that:

Exec "Taskkill /IM TcPowerPack.EXE /F"
sleep "500"

Exec "Taskkill /IM TOTALCMD64.EXE /F"
sleep "500"

Adding codesigned certificates
One of the challenges with creating an installer is that it might be blocked by Antivirus scanners or Windows itself. So, in an effort to avoid this, I self-sign the installer. This is a paid option that utilizes codesigning tools in Microsoft’s SDK as well as a certificate from Code Signing Store ($74 /year). These certificates are helpful for other things too, not use signing .exe’s.

The code to achieve this looks like the following (this was adapted from the Winamp forums):

1. Define the variables at the top of your NSI:

!define OutFileSignCertificate "C:\codecert.pfx"
!define OutFileSignPassword "password"

2. Define how the signtool commands will run:

!define OutFileSignSHA1 "C:\CodeSign\SignTool sign /f ${OutFileSignCertificate} /p ${OutFileSignPassword} /fd sha1 /t http://timestamp.comodoca.com /v"
!define OutFileSignSHA256 "C:\CodeSign\SignTool sign /f ${OutFileSignCertificate} /p ${OutFileSignPassword} /fd sha256 /tr http://timestamp.comodoca.com?td=sha256 /td sha256 /as /v"

3. At the end of the NSI script, sign the installer (the sleep directive could be used too):

!finalize "${OutFileSignSHA1} ${OutFileName}" # CodeSigning with SHA1/AuthentiCode
!finalize "PING -n 5 127.0.0.1 >nul" 
!finalize "${OutFileSignSHA256} ${OutFileName}" # CodeSigning with SHA256/RFC 3161
!finalize "PING -n 5 127.0.0.1 >nul"

Your NSIS setup file is now going to be signed with both sha1 and sha256:

Compressing the setup
I also wanted to compress the installer with a password so only I could use it and, as a zip distribution is easier. With the help of a local 7Zip installation, I used that tool and the !finalize statement to make this happen at the bottom of my NSI script. Replace the word ‘password’ with your own password if you want to try this:

!finalize "$\"C:\Program Files\7-Zip\7z.exe$\" a -p$password -sdel $\"${ProgramName}.zip$\" $\"${OutFileName}$\""

Adjusting Total Commander

As a file manager, Total Commander is amazing, but by adding more to this tool, you’ll be able to do so much more. Here are a few things I do – all to the start menu.

Adding Utilities

Total Commander can be like a swiss army knife for the most common things you use. For me, I like to add tools like WizTree, WinSCP, Rufus, OO AppBuster and others. How do I do this?

At the root of Total Commander’s folder structure (called %COMMANDER_PATH%), I place a folder called \Tools – under here, I place either the portable executable or a folder if the application has supporting files. Then, in the menu, I click ‘Start’ and ‘Change Start Menu’ – you’ll get an interface that lets you add items and commands.

One example, launching Netscan, the command after I place the files in the appropriate place is:
%COMMANDER_PATH%\Tools\netscan.exe

Adding Quick Links to Shortcuts

When administering Windows computers you’re going to want to get at certain tools as fast as possible, but in Windows itself (especially as a limited user), that’s not always easy – even with the Windows + X menu. To get at these tools, I add a submenu called ‘Windows’ that gets me admin-level access quickly. Here are some examples:

Computer Management (as Admin)

powershell Start-Process "mmc.exe compmgmt.msc" -Verb runAs

Disk Cleanup (as Admin)

powershell Start-Process "cleanmgr" -Verb runAs

Windows Update

ms-settings:windowsupdate

Turn off hibernate (and delete hiberfile.sys)

powershell Start-Process "powercfg.exe" -ArgumentList "'/hibernate off'" -Verb runAs

Manage Outlook Profiles

outlook.exe /manageprofiles

Running Scripts

In addition to tools, there are scripts that I’ll launch manually (out of %COMMANDER_PATH%\Scripts), but there are times when a specific Powershell script would be useful. In one example, working with Lenovo machines, I wanted to enable what was possible in the BIOS regarding Wake On Lan. The following script was then added to Total Commander’s Start menu:

Lenovo Enable Wake ON LAN

powershell -noexit -executionpolicy bypass -File %COMMANDER_PATH%\scripts\lenovowol.ps1

Contents of the above lenovowol.ps1 file:

(gwmi -class Lenovo_SetBiosSetting -namespace root\wmi).SetBiosSetting("Wake on LAN,Primary")
(gwmi -class Lenovo_SetBiosSetting -namespace root\wmi).SetBiosSetting("Enhanced Power Saving Mode,Disabled")
(gwmi -class Lenovo_SaveBiosSettings -namespace root\wmi).SaveBiosSettings()
gwmi -class Lenovo_BiosSetting -namespace root\wmi | ForEach-Object {if ($_.CurrentSetting -ne "") {Write-Host $_.CurrentSetting.replace(","," = ")}}

Installing Applications

Thanks to Microsoft’s winget package manager, I’ve been exploring more the idea of using the menu to install applications on the fly (especially great for setting up new computers). You might choose to use another package manager like chocolatey – the outcome is the same. For this I add a new sub-menu called ‘Install’ and add items like this:

Acrobat Reader DC

winget install -e --id Adobe.Acrobat.Reader.64-bit --accept-source-agreements --accept-package-agreements

It’s important to note that I always want to strike the balance between useful tools and the size they consume. I’m always looking for better, faster and smaller tools to add to the mix. I’m always updating these tools and making sure the newest is installed and removing things that aren’t as useful or redundant. I like to keep Total Commander as clean as possible and as useful as possible. If you also like to extend your installation, I’d love to know more about it.