Showing posts with label Windows. Show all posts
Showing posts with label Windows. Show all posts

06/11/2025

[Windows] Delete recovery partition

Windows disk manager lets you create, delete, modify partitions on connected drives, but does not allow deleting the recovery partition. To do that, you can use the diskpart utility which can be run from an Administator command line. The following commands will allow you to delete the partition, replace X with the desired disk and partition

diskpart

list disk

select disk X

list partition

select partition X

delete partition override


01/11/2025

[Windows 11] Disable lnk resolver

Windows has a set of features on NTFS file systems called "shortcut resolver" that allow the system to search for a shortcut target in the filesystem if it gets moved around after a link to it is created.

This is convenient normally in case you create a shortcut to something, then move said something somewhere else as usually the shortcut would stop working and throw an error when accessed instead. However, it can lead to security issues as a new attack vector is introduced that could allow a malicious actor to hijack the target and point to something unwanted instead.

The features can be disabled on Windows 11 by enabling some group policies (Start->Run->gpedit.msc):

  • User Configuration\Administrative Templates\Start Menu and Taskbar\Do not use the search-based method when resolving shell shortcuts
  • User Configuration\Administrative Templates\Start Menu and Taskbar\Do not use the tracking-based method when resolving shell shortcuts
  • User Configuration\Administrative Templates\Windows Components\File Explorer\Do not track shell shortcuts during roaming
Additionally the "Distributed Link Tracking Client" service can be disabled (Start->Run->services.msc)

26/07/2025

[Lenovo] Fix PSR screen issues with AMD graphics

Some recent Lenovo laptops come with displays theoretically supporting PSR (Panel Self Refresh) techology which supposedly would improve battery life.

On systems with AMD graphics, both the proprietary drivers and the ones packaged by Lenovo incorrectly implement support for it, leading to issues such as screen flickering, screen tearing and video stuttering.

The workaround is to force disable PSR in Windows registry, by opening regedit and looking for this entry:

Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}\0000

then modifying or creating a key DWORD 32 bit named DalPSRFeatureEnable with value 0

Afterwards simply reboot the system.

Even though in theory disabling PSR could lead to worse battery life and higher GPU temperatures, I have not seen noticeable differences after a month of use, naturally it might vary for others, therefore monitor your system to detect issues in case.

To reenable it, simply change the value to 1

24/04/2025

[Windows 11] Uninstall widgets app

If you do not need the widgets functionality on your Windows machine, you can disable it from settings or completely remove it with:

winget uninstall "windows web experience pack"

[Windows] Hash a file

Windows offers a builtin tool to compute the hash of a file (example MD5):

CertUtil -hashfile FILENAME MD5

To view the list of supported options and hash algorithms:

CertUtil -hashfile -?

23/04/2025

[Windows 11] Disable telemetry and diagnostic data

Windows 11 collects some data and allows some configuration under Settings > Privacy & Security > Diagnostics & Feedback however you are not allowed to completely disable it. If you wanted to do so, you could apply a policy using the Local Group Policy Editor app (gpedit).

Find the Local Computer Policy > Administrative Templates > Windows Components > Data Collection and Preview Builds > Allow Diagnostic Data

Click to modify it, enable it and set it to "Diagnostic data off"

You can then logout and login again or run from a terminal the command to force reload policies:

gpupdate /force

[Windows 11] Remove PhoneLink app

Removing the PhoneLink app on Windows, is as easy as running (from administrator shell):

Get-AppxPackage Microsoft.YourPhone -AllUsers | Remove-AppxPackage

12/03/2025

[Windows 11] Initial setup without forced login

When setting up Windows 11 from a new installation, you will be guided through a graphical setup at boot. 

Since every other company decided to force onto users annoying choices without much backlash, also Microsoft though to participate in the fun now by forcing you to login to your Microsoft account (or create a new one) during this process.

To avoid this for the moment, you can run a couple commands during the setup. After choosing the language for the setup process, press SHIFT+F10 to open a command prompt, then enter:

OOBE\BYPASSNRO

which will make the PC reboot. Once you are back into the setup process, choose the language again (if prompted) and press again SHIFT+F10 to get back into the command prompt, this time enter:

ipconfig /release

to disconnect from any network you might be connected to.

Finally moving forward in the process, when you reach the "connect to the internet" stage, you will have the option to click on a small link saying "I don't have internet", you will then be prompted to create a local account on your PC.

09/11/2023

[Windows 11] Default show more options explorer right click menu (old UI behavior)

One change with Windows 11 is that the right click menu in Explorer was replaced with some condensed version where the old behavior is hidden behind a "Show more options" entry. This makes some actions slower to find and quite annoying, for example 7-zip or Notepad++

To revert it to the nicer old UI you can add a personal registry key, by typing this in a command prompt:

reg.exe add "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" /f /ve

Then logout and login again or restart explorer process to see the effect take place.

This is setting an override on the default config found under (which remains untouched):

Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InProcServer32

To undo the change, simply delete the registry key created by the command.

21/04/2020

[Windows] Share environment variables in Windows Subsystem for Linux

Now that you have your fancy WSL up and running, you want to use it and all your environment variables are NOT available (of course).

Luckily there is a workaround, using the WSLENV variable. Unfortunately, it is not a direct 1:1 translation of your existing variables, rather you will need to craft them manually and convert between the two environments before you run a command or switch environment.

For example, to pass your JAVA_HOME correctly to wsl:

set JAVA_HOME=%JAVA_HOME%
set WSLENV=JAVA_HOME/up
wsl
echo $JAVA_HOME

And the magic is behind that last /up flag which says: set the value when invoking WSL from Windows (u) and translate between Windows and Unix paths (p)

WARNING: spaces are NOT escaped
WARNING2: only ONE variable is shared, so you cannot share both JAVA_HOME and PATH for example at the same time

[Windows] Activate and configure Windows Subsystem for Linux

Windows 10 introduced an update that adds a very cool feature: Windows Subsystem for Linux. If you are a fan of Cygwin, or similar tools, you will greatly like this feature as well.

Setup could be a bit more straightforward, but still not a big issue:

  1. Enable Windows Subsystem for Linux as a Windows feature from Control Panel > Programs and Features > Turn Windows features on or off
  2. Reboot
  3. Make sure LxssManager service is running
  4. Install a Linux distro from Windows store, search for "WSL" and pick the one you prefer, for example Alpine or Ubuntu, if no distro is installed, you get an error instead:
Windows Subsystem for Linux has no installed distributions. Distributions can be installed by visiting the Windows Store: https://aka.ms/wslstore Press any key to continue...

And going to that link brings you nowhere.. so just install it yourself from the store.

After the installation is completed (might ask you to setup a user and password), you can open any command prompt and type wsl to launch it.

Be careful, that command was different in the past: lxrun or bash and there are apparently 2 versions of WSL as well, use whatever makes it run for you

17/04/2020

[Windows] Store command output in variable in batch script

For whatever reason, storing the output of a command into a variable from a batch script is not easy at all:

FOR /F "tokens=*" %%g IN ('your_command ^| with_escaped_pipe_if_you_need_it') do (SET VAR=%%g)

07/04/2020

[Windows] Custom keyboard layout QWERTZ to QWERTY

Some people are unfortunate enough to use a QWERTZ keyboard layout (and then there are the French), not because they need ready access to that specific letter, but maybe just to avoid losing yet another war.

Of course, for us with functioning opposable thumbs, this might introduce some difficulties as years of CTRL+Z trained our muscle memory for ready undo (Z) rather than redo (Y).

Windows provides a tool: Microsoft Keyboard Layout creator, that helps us overcome this by defining a new key map and generate an installable keyboard layout. Cool.

Install it, File - Load existing keyboard, pick your ümläuted keyboard of choice and invert the z and y keys to restore universe order. Done.

Not so fast. What about UPPERCASE Z and Y? You need to change those too. On the left side, check the Shift under Shift states section and perform the binding again, this time for capital Z and Y. Done.

Not so fast, What about the shortcuts that were using Z and Y? They still map to the old layout where the keys were inverted, you need to change those too. Unfortunately, it can't be done from the tool. 

No worries, save your project and open your .klc file with a text editor and search for the line defining your Z and Y keys, they will look like this (example for the y key):

15 Z 1 y Y -1 -1 // LATIN SMALL LETTER Y, LATIN CAPITAL LETTER Y

As you can see, almost all changes were done, but the damn keys are still left in the wrong place in the underlying mapping. Simply change them to reflect the correct mapping (example for the y key):

15 Y 1 y Y -1 -1 // LATIN SMALL LETTER Y, LATIN CAPITAL LETTER Y

Then save and reopen the file with the tool. Now finally: Project - Build DLL and setup package to generate the installer, run it, and we have our new keyboard available to select in the language list for available keyboards.

If the tool fails to build, try to install it in c:\mklc14 folder as it might fail if it is installed in another location or in a directory containing spaces

Of course, you need to restart the system in order for ALL remappings to take effect.

22/03/2018

[Windows] Blood Bowl 2 offline league manager

If you are a fan of Blood Bowl and purchased either Blood Bowl 2 or Blood Bowl 2: Legendary Edition on PC, you might be - as many others - extremely disappointed at the lack of an offline (hotseat) league option.

This command line tool provides capability to edit - AT YOUR OWN RISK - the SQLite database where team and player information is stored so that, with a bit of paper tracking, you can update the stats after a friendly match.

This tool is not a cheat/trainer!, it only allows you to edit offline team data, much like the "Custom team" feature of the Legendary Edition, except that feature is only usable at team creation.
This tool is based on the rules found in the Blood Bowl Living Rulebook version 6 and might NOT reflect the actual rules implemented in the game - yet, since I saw some rule tables in the DB, and need to investigate further there..

This tool is an alpha version!, it works without hiccups - but its a barebone tool with some open todos and limitations and the user experience can be further improved, but it works as a starting point if you, like me, crave this feature! :)

You can find the BBManager project on my GitHub and download the compiled jar as well.

Please refer to the project README to find out how to use the tool.

22/05/2015

[Windows Server 2012] Add role fails

When trying to add a role (eg ActiveDirectory) to a Windows Server 2012 machine, I found that it would try to enable the components, but it would always fail in the end saying that the machine needed a reboot. It doesn't matter how many reboots you do, it will still fail.

The reason was that these services had to be enabled before trying to add the new role:


  • Server
  • Workstation
  • Computer Browser
  • TCP/IP NetBIOS Helper

29/11/2014

[Windows Server] Disable shutdown reason tracker

Every time you halt or reboot your Windows Server machine, you'll have to specify a reason before you can proceed.
This can be disabled by running:

gpedit.msc

then browsing to

Computer Configuration->Administrative Templates->System then searching for the entry: Display Shutdown Event Tracker and setting it to disabled.


[Windows Server] Change password policy

On Windows Server you can change the password policy, eg:

  • User cannot change password
  • Password must be at least X characters long
  • Password expires after X days
  • ...
Either locally for the server:

secpol.msc

Or for the whole domain:

gpedit.msc

Run either one of these tools depending on your needs then browse to Account Policies->Password Policy

[Windows Server] Disable Server Manager auto start at login

You can block Windows Server Manager from starting automatically at login from its configuration.

Open Server Manager, then click on the Manage button and choose "Server Manager properties", you'll have the choice there.

[Windows Server] Enable automatic login

On Windows Server 2008/2012 it's possible to enable automatic login if the server is NOT a domain controller.

Simply run:

netplwiz.exe

Found under WIN_INSTALL_DIR\System32, and uncheck "Users must enter a username [...]". You'll have to insert you username and password and at the next reboot you'll brought directly to your desktop.

If your server is a Domain Controller (DC) too, then you cannot use this tool, but will have to uncheck the same setting from the "Active Directory Users and Computers" snap-in

26/10/2014

[Windows 7] Create repair USB key to run bootrec

Say that your Windows 7 machine had a problem and you can no longer boot in; usually this can be easily fixed by running the bootrec utility to repair the MBR/boot sector

For some very important reasons, this extremely useful tool can only be run from a Windows install DVD and you don't have direct access to it, even from the safe mode. Luckily, you can create a bootable USB key where to place the Windows RE without having to get said DVD - only catch: you'll need access to a working Windows 7 PC.

Now that your friend generously gave you permission to use his PC, let's get started.