25. May 2021

Windows Terminal – How to add a custom shell to dropdown menu with JSON Fragment Extension

Windows Terminal allows you to use and manage shells for CMD, PowerShell or WSL2 in one window.

Windows Terminal also allows registering custom shells to the application. One option is to edit the profile manually via Settings.

It’s also possible to use the so-called JSON Fragment Extension which lets you drop a JSON file into a directory and Windows Terminal will load information from the file. The major advantage is that you can move the file between computers without worrying about damaging HJSON format of the original configuration file.

The instructions on the Microsoft site are not very clear on how to add the JSON and I had to use debugger to determine the proper location.

First of all create a directory for your application (e.g. IPython) with following PowerShell command:

mkdir "$env:LocalAppData\Microsoft\Windows Terminal\Fragments\IPython\"

Open a file with .json file extension and specify there following content (e.g. fragment.json with full path “$env:LocalAppData\Microsoft\Windows Terminal\Fragments\IPython\fragment.json”):


Save the file, close Windows Terminal, open new Windows Terminal, and IPython will be visible in the list of available terminals.

Select the IPython and you’ll get a new tab with the interpreter.

13. May 2021

Windows on Lenovo T14 is sluggish after resuming from sleep? Simple solution.

One thing that you might notice on Lenovo T14 with Windows is that sometimes the whole system is sluggish, UI is not responsive. One solution is to reboot the computer and then it works without problem.
The problem occurs more often when you turn on “Night light” feature which changes the color of the whole UI.
The issue seems to be caused by some power management. To workaround, the issue clicks the battery icon and dial-up Power mode to Best Performance.

The Best Performance setting does not apply just to situations when the computer is on battery, it also changes behavior when the computer is connected to a power supply. Best Performance will also enable fans to operate at a higher speed so the computer will be noisier, but it will give you an extra nuget of CPU power.

7. May 2021

How to speed up Linux on WSL2? Common mistake when upgrading from WSL1

According to Microsoft WSL2 is way faster than WSL1 for running Linux images. So, why even after upgrade to WSL2 is Linux running slow and with the same IO inefficiency like it was on WSL1?

The reason is simple. Even though the WSL2 was added to the operating system, the old images are running on WSL1. You can verify it by command:

wsl -l -v


  NAME                   STATE           VERSION
* openSUSE-Leap-15.2     Stopped         1
  Ubuntu                 Stopped         1
  docker-desktop-data    Stopped         2

As you can see both Ubuntu and openSUSE has set version to 1 which means that these images runs on WSL1. It’s necessary to explicitly change the version by following commands:

wsl --shutdown
wsl --set-version "Ubuntu" 2
wsl --set-version "openSUSE-Leap-15.2" 2 

The conversion will take some time. Output:

Conversion in progress, this may take a few minutes...
For information on key differences with WSL 2 please visit https://aka.ms/wsl2
Conversion complete.

Now you can verify the version of WSL for the image:

wsl -l -v
  NAME                   STATE           VERSION
* openSUSE-Leap-15.2     Stopped         2
  Ubuntu                 Stopped         2
  docker-desktop-data    Stopped         2

Simply start the shell of the distribution and you’ll experience better performance.

It’s also possible to set version for future images by command:

wsl --set-default-version 2

6. May 2021

How to find COM port of connected IoT device on Windows

When you need to talk to an IoT device over RS232 connected to the computer via USB cable, the first thing that you need to know is the name of the port. Windows assigns port numbers like COM3, COM7, COM21 to connected devices. How to find the number?
The quick way is to type the following command:

The quick way is to type following command:


The output:

COM10 = \Device\VCP1
COM9 = \Device\VCP0

For older versions of Windows you can use:


The output:

Status for device COM9:
    Baud:            1200
    Parity:          None
    Data Bits:       7
    Stop Bits:       1
    Timeout:         OFF
    XON/XOFF:        OFF
    CTS handshaking: OFF
    DSR handshaking: OFF
    DSR sensitivity: OFF
    DTR circuit:     ON
    RTS circuit:     ON

You can find all these hints also on SuperUser.

But what to do when the device is connected and the list of COM ports is empty?

The most common reason is that Windows is missing one of the following drivers:

Steps to resolve the problem:

The system should pick the installed driver and assign it to the device.

You can use also idf-env tool to install the drivers by following PowerShell commands:

Invoke-WebRequest 'https://dl.espressif.com/dl/idf-env/idf-env.exe' -OutFile .\idf-env.exe
.\idf-env.exe driver install --ftdi --silabs

Footnote: following PowerShell command might NOT list all connected IoT COM devices, but you can find it on many forums on the internet. Often it displays just COM3 and COM4 which are not associated with IoT device.

Get-WMIObject Win32_SerialPort | Select-Object Name,DeviceID,Description

3. May 2021

How to add/remove device driver from command-line on Windows

Windows operating system contains a tool that allows manipulation with system drivers stored in .INF and .CAT files. The operation requires Administrator privileges.

Command to install the driver:

pnputil /add-driver my-driver.inf /install

The correct installation display the following result:

Microsoft PnP Utility

Adding driver package:  my-driver.inf
Driver package added successfully.
Published Name:         oem3.inf

Total driver packages:  1
Added driver packages:  1

To verify the result you can plug the device and it should pick the correct driver. The system copied content from my-driver.inf to C:\Windows\INF\oem3.inf. The number in file name might be different.

The remove the driver from the system and perform uninstallation of the driver from devices type following command:

pnputil /remove-driver my-driver.inf /uninstall

Expected result:

Microsoft PnP Utility

Driver package deleted successfully.