27. April 2021

Quick way to clear all Windows Defender exclusions

Windows Defender has support for a list of exclusions that won’t be considered for scanning. The UI for manipulating with exclusions is quite simple and does not allow operations on multiple exclusions at once. Fortunately, there are PowerShell commands which can help.

These commands are Add-MpPreference, Get-MpPreference, and Remove-MpPreference.

Following commands allows to quickly remove all exclusions of Path. The command must be started in Administrator’s shell:

foreach ($Path in $Paths) { Remove-MpPreference -ExclusionPath $Path }

A similar principle can be applied on the rest of the exclusions: ExclusionExtension, ExclusionIpAddress, ExclusionProcess

foreach ($Extension in $Extensions) { Remove-MpPreference -ExclusionExtension $Extension }

foreach ($Process in $Processes) { Remove-MpPreference -ExclusionProcess $Process }

22. April 2021

How to run Linux GUI application on Windows WSL2 with MobaXterm and Windows Terminal

MobaXterm is a great software that allows running applications from Linux on Windows in a nice integrated way without the need of installing extra XServer.

MobaXterm has also support for WSL2 which makes it easy to launch Linux GUI applications from Linux on Windows.

After installation of Linux distribution like Ubuntu or openSUSE on WSL2, you will find new sessions with the prefix WSL in MobaXterm. Simply click the session label and a new terminal will be automatically configured to talk to the local XServer.

Now you can start any GUI command, e.g. xeyes.

The same XServer from MobaXterm can be used also from other terminals and shells like Windows Terminal. It’s sufficient to export environment variable DISPLAY in the Linux WSL2 session:

export DISPLAY=

Note: xeyes are part of x11-apps, you can install them by command

sudo apt install x11-apps

20. April 2021

How to statically link Rust application for Windows

Rust compiler can generate a single binary that contains all dependencies. This is a great feature for creating stand-alone tools or tools for containers.

There is one gotcha for Windows which does not appear on a developer’s machine. When you move the application to a brand new installation of Windows or you try to start the in Windows Docker Container which contains Windows for Datacenters the app won’t start.

Why? The system is missing Microsoft Visual C++ Redistributable 2015-2019 (vc_redist) which you can download from microsoft.com.

It’s quite inconvenient to force the user to install the package in the case of a stand-alone Rust tool. The package installation even requires elevation of privileges.

The alternative approach to distributing vc_redist is to statically link CRT library into the application. It will result in a slightly bigger application around +100KB.

It’s necessary to tell rustc to perform static linking of CRT.

In the project create file .cargo/config.toml:

rustflags = ["-C", "target-feature=+crt-static"]

Rebuild the application and the new binary is statically linked and can run even on Windows 8 without vc_redist.

The interesting part is how to determine the proper target name which is on the first line of the example configuration. Many examples on the internet are referring to target.i686-pc-windows-msvc which does not work. Use the following command to determine parts of the name of the target:

rustc --print cfg

The target name is composed of values on the lines above.

1. December 2020

How to switch tabs in Windows Terminal

Windows Terminal is very versatile shell for Windows which allows to run CMD, PowerShell or Linux in WSL2. The terminal also supports tabs.

To switch between tabs you can use:

  • CTRL+Tab – switch to next tab
  • CTRL+Shift+Tab – switch to previous tab
  • If you’d like to use own keyboard shortcuts like CTRL+PgUp, CTRL+PgDown, then just open Settings CTRL+, and enter following code into section actions:

    ..."actions":  [
      { "command": "nextTab", "keys": "ctrl+pgdn" },
      { "command": "prevTab", "keys": "ctrl+pgup" }

9. May 2019

How to switch tabs in ConEmu-Maximus5

ConEmu-Maximus5 contain simple keyboard shortcut to switch between active tabs on Windows:

CTRL + Tab – switch to the next tab
CTRL + Shift + Tab – switch to the previous tab