Skip to main content

Windows

Install

Bypass the network requirement (OOBE)

At the "Oops, you've lost internet connection" screen during Windows 11 setup, press Shift + F10 and run:

OOBE\BYPASSNRO

Boot from a VHDX

:: With the Windows 11 ISO mounted
Dism /apply-image /imagefile:F:\sources\install.wim /index:1 /ApplyDir:V:\
bcdboot V:\Windows

System administration

:: Test a user account and password (test login)
runas /u:yourdomain\a_test_user notepad.exe

:: Kill a process by PID
taskkill /f /PID 6092

:: Reboot into the boot options / settings menu
shutdown /r /o /f /t 00

Activation error 0x80070002: sync the system time, then run Windows Update.

Restart Explorer when the desktop hangs

taskkill /f /IM explorer.exe
start explorer.exe
exit

Remove one autocomplete entry

Highlight the suggestion in the address bar or form field, then press Shift + Fn + Delete.

Reload the graphics driver

Press Win + Ctrl + Shift + B.

Registry tweaks

; Classic right-click menu (Windows 11)
reg add HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32 /ve /f

; Desktop icon spacing
HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics
IconSpacing = -1125
IconVerticalSpacing = -1125

; RDP client history (delete MRU* entries)
HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\Default

Default resolution

Avoid the window layout shrinking when the display goes offline. In regedit:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\GraphicsDrivers\Configuration

Find SIMULATED...:
PrimSurfSize.cx = 1920
PrimSurfSize.cy = 1080

Subfolder 00...:
ActiveSize.cx = 1024
ActiveSize.cy = 768

On the monitor OSD, disable Deep Sleep.

Networking

# Check a port
tnc 192.168.1.2 -port 3389

# Check which process is using a port
netstat -aon | findstr "80"

# Check a task by PID
tasklist | findstr "7532"

# "Ping: Transmit Failed. General Failure"
ipconfig /flushdns
netsh winsock reset

Enable or disable ping

Creates or blocks exceptions in the default Windows firewall rules.

:: Allow incoming echo requests (IPv4 / IPv6)
netsh advfirewall firewall add rule name="ICMP Allow incoming V4 echo request" protocol="icmpv4:8,any" dir=in action=allow
netsh advfirewall firewall add rule name="ICMP Allow incoming V6 echo request" protocol="icmpv6:8,any" dir=in action=allow

:: Block them
netsh advfirewall firewall add rule name="ICMP Allow incoming V4 echo request" protocol=icmpv4:8,any dir=in action=block
netsh advfirewall firewall add rule name="ICMP Allow incoming V6 echo request" protocol=icmpv6:8,any dir=in action=block

IPBan

IPBan automatically builds firewall rules from abusive login attempts.

# Install (run PowerShell as administrator)
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/DigitalRuby/IPBan/master/IPBanCore/Windows/Scripts/install_latest.ps1'))

# Older manual install (Windows 11 does not generate the log this way)
dir C:\my\service\IPBan-Windows | Unblock-File
New-Service -Name "IPBAN" -BinaryPathName "c:\path\to\service\DigitalRuby.IPBan.exe" -StartupType automatic -DisplayName "IPBAN" -Description "Automatically builds firewall rules for abusive login attempts: https://github.com/DigitalRuby/IPBan"
Get-WmiObject win32_service -Filter "name='IPBAN'"
Start-Service IPBAN
sc.exe config IPBAN start= delayed-auto

Enable the audit policy so failed logins are logged:

:: English Windows
auditpol /set /category:"Logon/Logoff" /success:enable /failure:enable
auditpol /set /category:"Account Logon" /success:enable /failure:enable

:: Traditional Chinese Windows
auditpol /set /category:"登入/登出" /success:enable /failure:enable
auditpol /set /category:"帳戶登入" /success:enable /failure:enable

Configuration lives under C:\Program Files\IPBan:

  • ipban.config — main configuration.
  • ban.txt — bans an IP at the next CycleTime.
  • unban.txt — unbans an IP at the next CycleTime.

Search the log for a matching entry (address, user name, source):

DigitalRuby.IPBanCore.Logger|Login succeeded

Uninstall:

sc.exe stop IPBAN
sc.exe delete IPBAN

SSH

Log in to Linux from Windows

On the Windows side, open PowerShell and generate a key pair:

ssh-keygen
# Saves to C:\Users\%USERNAME%\.ssh\id_rsa and id_rsa.pub

# A named key elsewhere
ssh-keygen -t rsa -b 4096 -C "[email protected]" -f D:\id_rsa

Only when using multiple keys do you need a config file at C:\Users\%USERNAME%\.ssh\config:

Host MY-HOST
Hostname 127.0.0.1
Port 80
User my
IdentityFile ~/.ssh/id_rsa

If you see WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!, delete the stale entry in .ssh/known_hosts.

On the Linux side, install the public key:

# Upload id_rsa.pub first, then:
cd ~/
mkdir .ssh && chmod 700 .ssh
touch .ssh/authorized_keys && chmod 600 .ssh/authorized_keys
cat id_rsa.pub >> .ssh/authorized_keys
rm id_rsa.pub

MSYS2

# Update the package database and base packages
pacman -Syu
# Update the rest of the base packages
pacman -Su

# mingw-w64 GCC toolchain
pacman -S --needed base-devel mingw-w64-x86_64-toolchain

# jq — command-line JSON processor
pacman -S mingw-w64-x86_64-jq

# Gradle
pacman -S gradle

# Set PATH
export PATH=/C/tool/hugo_0.93.3_Windows-64bit:$PATH

Code signing (for PM2 deploy)

If PM2 fails with spawn sh ENOENT, use Git Bash. To sign Windows binaries:

pacman -S mingw-w64-x86_64-osslsigncode
pacman -S winpty # fixes "cannot prompt input"; restart MSYS2 afterward

winpty openssl pkcs12 -in Certificates-Unify.p12 -nocerts -out Certificates-Unify.key
openssl x509 -in win-codesign.cer -out win-codesign.cert -inform DER # cer == cert
./detached-sig-create.sh -key Certificates-Unify.key

Python

# Python 3.x
python --version
pip3 install --upgrade pip

pip install virtualenv
python -m venv .venv
.\.venv\Scripts\activate.bat
deactivate

pip install -r requirements.txt
pip install requests
pip freeze > requirements.txt

pip install -U urllib3
pip install -v requests2==2.27.1

Windows Terminal

Add a new profile to settings.json:

"profiles": {
"list": [
{
"commandline": "ssh [email protected]",
"name": "vm7 ubuntu20.04Server"
}
]
}

In the PowerShell profile, insert a multi-line command with Ctrl+Q then Shift+A.

# Verify RabbitMQ credentials are valid
curl -i -u user:passw0rd http://vmwin2022:15672/api/whoami

MongoDB

Start PowerShell as administrator and create the data, log, and config paths:

mkdir C:\temp\mongo\data\db
mkdir C:\temp\mongo\data\log

Create C:\temp\mongo\data\mongod.cfg:

systemLog:
destination: file
path: C:\temp\mongo\data\log\mongod.log
storage:
dbPath: C:\temp\mongo\data\db

Install and run it as a service:

mongod.exe --config "C:\temp\mongo\data\mongod.cfg" --install
net start MongoDB
mongo.exe
net stop MongoDB

WSL2

wsl --install # install WSL

wsl -l -v # which versions are installed
wsl --list --verbose

wsl --set-version DISTRO_NAME 2 # change a distro to WSL 2

wsl -d Ubuntu # start a distro

Applications

PotPlayer

# Add to C:\Windows\System32\drivers\etc\hosts
127.0.0.1 get.daum.net

VMware

Ubuntu 22.04 LTS clipboard sharing does not work under Wayland. At the login screen, switch the session from Wayland to Xorg.

VPN kill switch

If the OpenVPN connection drops frequently, check that the Windows firewall is not blocking everything except the VPN client. To build a kill switch:

  1. Open Windows Defender Firewall with Advanced Security on Local Computer.
  2. Set Inbound and Outbound to Block for the Domain and Private profiles.
  3. Add outbound rules allowing Remote UDP ports 53 and 1194.
  4. Add an inbound rule scoped to Remote 10.8.0.1-10.8.0.254.
  5. Add an outbound rule scoped to Local 10.8.0.1-10.8.0.254.

Windows Store

Fix the ms-windows-store:PurgeCaches — The app didn't start error:

Get-AppXPackage | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}

Install an .msixbundle

Add-AppxPackage WindowsCamera_2022.2210.9.Msixbundle

Let a VM guest open host applications

Make sure the virtual machine configuration allows the guest to open host applications. (Windows 11 Lite lacks Microsoft Edge.)

Split audio from a video

ffmpeg -i input.mp4 -vn -acodec copy output.m4a

Reference: International English vs. English

Windows International English targets British-English users; the English edition targets users in the United States.

International EnglishEnglish
DialectBritish EnglishAmerican English
Time formatlocal 24-hourUS Pacific (PST), 12-hour
Spellingcolourcolor