Windows Tricks
Former gist: https://chk.me/4KijErW
Most of the commands below can be run from the “Run Box” with the shortcuts
WIN+RorWIN+E CTRL+L.To run the commands with admin privileges, hit
Ctrl+Shift+Enterafter typing them.See also the keyboard shortcuts: https://support.microsoft.com/en-us/accessibility/windows/keyboard-shortcuts-in-windows https://support.microsoft.com/fr-fr/accessibility/windows/keyboard-shortcuts-in-windows
SHELLS & TERMINALS
⚠️ A terminal hosts a shell: the terminal (Windows Terminal, Console Host) is the app that displays and relays input, while the shell (pwsh, PowerShell, cmd) is the command interpreter. Use ✅ PowerShell (v7) not 🚫 Windows PowerShell (v5). They are different applications. https://learn.microsoft.com/en-us/powershell/scripting/whats-new/differences-from-windows-powershell
TERMINALS (EMULATORS)
| Command | Name |
|---|---|
wt |
✅ Windows Terminal (1.24.2607.10001) |
conhost |
Windows Console Host (10.0.26100.8875) — host process for console apps |
SHELLS (COMMAND INTERPRETERS)
| Command | Name |
|---|---|
pwsh |
✅ PowerShell (7.6.6) |
powershell |
🚫 Windows PowerShell (5.1.26100.9444) |
powershell_ise |
🚫 Windows PowerShell ISE (5.1.26100.9444) |
cmd |
COMMAND.COM, cmd.exe, Command Prompt, Windows Command Processor, Command Processor Shell |
GET THE VERSIONS
- PowerShell (v5) version
-
powershell -NoProfile -Command '$PSVersionTable.PSVersion.ToString()' -
# from inside a Windows PowerShell session: $PSVersionTable.PSVersion - PowerShell (v7) / pwsh version
-
pwsh --version -
# from inside a pwsh session: $PSVersionTable.PSVersion - Windows Terminal (wt) version
- installed package version (as reported by Windows):
-
(Get-AppxPackage Microsoft.WindowsTerminal).Version - running application version:
-
(Get-Process WindowsTerminal).MainModule.FileVersionInfo.ProductVersion - conhost version
-
(Get-Item C:\Windows\System32\conhost.exe).VersionInfo.ProductVersion
CUSTOM PROMPT — SHOW THE SHELL VERSION AFTER “PS”
The prompt is produced by a
promptfunction defined in the current-user host profile. Find the file path with$PROFILE.CurrentUserCurrentHost, then reload with. $PROFILE(or simply reopen the shell). The result dims the version in gray (ESC[90m).
- OPEN THE PROFILE FILE
-
notepad $PROFILE.CurrentUserCurrentHost - POWERSHELL (v7) PROFILE FILE
-
~/Documents/PowerShell/Microsoft.PowerShell_profile.ps1 - WINDOWS POWERSHELL (v5) PROFILE FILE
-
~/Documents/WindowsPowerShell/Microsoft.PowerShell_profile.ps1 - POWERSHELL (v7)
-
$PSStyle(7.2+) is available — dim withForeground.BrightBlack: -
function prompt { "PS $($PSStyle.Foreground.BrightBlack)$($PSVersionTable.PSVersion)$($PSStyle.Reset) $($executionContext.SessionState.Path.CurrentLocation)>`n" } - WINDOWS POWERSHELL (v5)
-
No
$PSStyleand no`eescape — build the ANSI gray with[char]27(ESC[90m): -
function prompt { "PS $([char]27)[90m$($PSVersionTable.PSVersion)$([char]27)[0m $($executionContext.SessionState.Path.CurrentLocation)>`n" } - RELOAD / TEST
-
. $PROFILE - RESULT
-
PS 7.6.6 C:\Users\nico> PS 5.1.26100.9444 C:\Users\nico>
BASIC COMMANDS
- GET WINDOWS VERSION
-
winver - GET SYSTEM INFORMATION
-
msinfo32 - SHUTDOWN / RESTART COMPUTER
- https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/shutdown
-
shutdown /p shutdown /r - OPEN DEVICE MANAGER
-
devmgmt.msc - OPEN TASK MANAGER (CTRL+SHIFT+ESC)
-
taskmgr - GET TERMINAL VERSION
-
Get-Process -Id $PID | Select-Object -ExpandProperty Path; $PSVersionTable.PSVersion.ToString() - SET “WINDOWS TERMINAL” AS DEFAULT
- IN SYSTEM/ADVANCED
- (OLD DEFAULT WAS “WINDOWS CONSOLE HOST”)
- search for terminal in:
-
ms-settings:developers - KILL A TASK
-
taskkill /im filename.exe /t /f - OPEN FONT DIRECTORY
-
%WINDIR%/Fonts shell:fonts %CSIDL_FONTS% - OPEN USER DIRECTORY
-
%HOMEPATH% %USERPROFILE% - OPEN 64 BIT PROGRAM FILES DIRECTORY (x64)
-
%PROGRAMFILES% - OPEN 32 BIT PROGRAM FILES DIRECTORY (x86)
-
%PROGRAMFILES(X86)% - OPEN “OPTIONAL FEATURES” WINDOW
-
OptionalFeatures.exe - OPEN WINDOWS EXPLORER
-
WIN+E - SHOW DESKTOP
-
WIN+D - SHOW SETTINGS
-
WIN+I - LOCK SCREEN
-
WIN+L - CHECK FOR UPDATES
-
ms-settings:windowsupdate - DISABLE ANNOYING SOUNDS
- click on 3rd tab “Sounds”
- choose “No Sounds” in dropdown “Sound Schemes”
-
mmsys.cpl - TOGGLE WIFI
-
ncpa.cpl
INSTALL
- NOTES
-
--scope machinerequests installation for all users; it does not select an installer format. -
Approve the administrator prompt when required.
--silentdoes not suppress this prompt. -
Windows Terminal uses
--scope user, as required by its MSIX package. - Wireshark uses the interactive EXE installer so that Npcap can also be installed for packet capture.
- See WinGet installation options and Wireshark installation instructions.
-
winget install -e --id Git.Git --source winget --scope machine --silent --accept-package-agreements --accept-source-agreements; winget install -e --id GitHub.cli --source winget --installer-type wix --scope machine --silent --accept-package-agreements --accept-source-agreements; winget install -e --id Microsoft.VisualStudioCode --source winget --scope machine --silent --accept-package-agreements --accept-source-agreements; winget install -e --id Hugo.Hugo.Extended --source winget --scope machine --silent --accept-package-agreements --accept-source-agreements; winget install -e --id PedroAlbanese.QREncode --source winget --scope machine --silent --accept-package-agreements --accept-source-agreements; git config --global user.name "NicHub on Windows"; git config --global user.email "nicolas.jeanmonod@gmail.com"; git clone https://github.com/ouilogique/enfants-kara.ch.git # set pwsh as default # Win+R pwsh # Ctrl+, # Default profile: PowerShell (And not Windows PowerShell) winget search Python # liste des versions Python disponibles winget install -e --id Microsoft.WindowsTerminal --source winget --scope user --silent --accept-package-agreements --accept-source-agreements; winget install -e --id Microsoft.PowerShell --source winget --installer-type wix --scope machine --silent --accept-package-agreements --accept-source-agreements; winget install -e --id Python.Python.3.14 --source winget --scope machine --silent --accept-package-agreements --accept-source-agreements; winget install -e --id OpenJS.NodeJS.LTS --source winget --installer-type wix --scope machine --silent --accept-package-agreements --accept-source-agreements; winget install -e --id Brave.Brave --source winget --scope machine --silent --accept-package-agreements --accept-source-agreements; winget install -e --id Mozilla.Firefox.DeveloperEdition --source winget --scope machine --silent --accept-package-agreements --accept-source-agreements; winget install -e --id BurntSushi.ripgrep.MSVC --source winget --scope machine --silent --accept-package-agreements --accept-source-agreements; winget install -e --id sharkdp.fd --source winget --scope machine --silent --accept-package-agreements --accept-source-agreements; winget install -e --id Neovim.Neovim --source winget --installer-type wix --scope machine --silent --accept-package-agreements --accept-source-agreements; winget install -e --id PuTTY.PuTTY --source winget --installer-type wix --scope machine --silent --accept-package-agreements --accept-source-agreements; winget install -e --id WiresharkFoundation.Wireshark --source winget --scope machine --installer-type nullsoft --interactive --accept-package-agreements --accept-source-agreements; winget install -e --id EclipseFoundation.Mosquitto --source winget --scope machine --silent --accept-package-agreements --accept-source-agreements; winget install -e --id Rclone.Rclone --source winget --scope machine --silent --accept-package-agreements --accept-source-agreements; winget install -e --id WinSCP.WinSCP --source winget --installer-type wix --scope machine --silent --accept-package-agreements --accept-source-agreements; # FileZilla Client is unavailable in the winget source. Download: https://filezilla-project.org/download.php?type=client # New installation: run from PowerShell as administrator. winget install -e --id Microsoft.VisualStudio.2022.BuildTools ` --source winget ` --scope machine ` --silent ` --accept-package-agreements ` --accept-source-agreements ` --override "--quiet --wait --norestart --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Component.VC.Tools.ARM64 --includeRecommended" npm install -g @openai/codex - Upgrade all
-
winget upgrade --all - Upgrade single
-
winget upgrade --id Microsoft.VisualStudioCode --installer-type inno --silent --accept-package-agreements --accept-source-agreements winget upgrade --id Microsoft.PowerShell --installer-type wix --silent --accept-package-agreements --accept-source-agreements
OPENCODE
Installation et mise à jour du client opencode sous Windows et sous WSL : voir la page dédiée.
👉 OPENCODE — le client embarqué dans l’app desktop (GUI), le redirecteur opencode.cmd, le port de service dédié et le retrait d’un ancien client.
WSL — Windows Subsystem for Linux
- Requirements
- Vérifier que la virtualisation est activée dans le BIOS.
-
Dans le BIOS, l’option s’appelle par ex. sur HP :
System Configuration/Virtualization Technology. - Vérifier dans PowerShell :
-
Get-CimInstance Win32_Processor | Select-Object Name, VirtualizationFirmwareEnabled Get-CimInstance Win32_ComputerSystem | Select-Object HypervisorPresent - Install WSL
-
wsl --install shutdown /r wsl -l -v wsl --install Ubuntu-26.04 - Usefull WSL commands
-
wsl # démarre dans la distro par défaut (Ubuntu) wsl -d Ubuntu # démarre une distro précise wsl -l -v # liste les distros installées + leur version wsl --update # met à jour WSL
OTHER
- Change default browser
-
ms-settings:defaultapps - Change color theme
-
ms-settings:colors - Coreutils: 78 Linux commands for powershell
- https://github.com/microsoft/coreutils
-
ls "C:\Program Files\coreutils\bin\" - https://youtu.be/Bg8FjRGuW_w?t=356
-
winget install -e --id Microsoft.Coreutils --source winget --scope machine --silent --accept-package-agreements --accept-source-agreements; - Install WSL1
-
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart - Optional
-
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart - Reboot
- Télécharger le MSI officiel Microsoft (WSL redistribuable)
-
curl.exe -L -o "$env:TEMP\wsl_update.msi" "https://aka.ms/wslupdate" Start-Process msiexec.exe -ArgumentList "/i","$env:TEMP\wsl_update.msi","/qn" -Wait wsl --set-default-version 1 wsl --install -d Ubuntu