Skip to main content

Overview

Command Not Found is a shell integration utility that provides intelligent command suggestions when you type a command that doesn’t exist in your system. It works with PowerShell and Command Prompt to suggest package installations, similar to the “command-not-found” feature in Linux distributions.
This utility integrates with Windows Package Manager (winget) to provide installation recommendations.

Activation

1

Enable in PowerToys

Open PowerToys Settings and enable Command Not Found
2

Shell Integration

The utility automatically integrates with your shells (PowerShell, CMD)
3

Use Naturally

Type commands in your terminal - suggestions appear automatically for unknown commands

Key Features

Intelligent Command Suggestions

Package Detection

Identifies which package contains the missing commandUses winget package database

Installation Commands

Provides exact winget command to installCopy-paste ready installation

Multi-Shell Support

Works in PowerShell and Command PromptAutomatic integration on enable

Similar Commands

Suggests similar available commandsHelps with typos and close matches

How It Works

When you type a command that doesn’t exist:
# Example: Trying to use 'wget' (not installed)
PS C:\> wget https://example.com
wget : The term 'wget' is not recognized as the name of a cmdlet...

Suggestion: Command 'wget' not found, but can be installed with:
  winget install GNU.Wget

Shell Integration

Command Not Found integrates with Windows shells through:
  • PowerShell Profile: Adds suggestion handler to $PROFILE
  • Command Prompt: Registers command processor extension
  • Automatic Updates: Keeps suggestion database current

Configuration

Enabling/Disabling

1

Open PowerToys Settings

Launch PowerToys Settings application
2

Navigate to Command Not Found

Find Command Not Found in the utilities list
3

Toggle State

Enable or disable the utility with the toggle switch
Changes to shell integration may require restarting your terminal sessions.

Supported Shells

Full integration with PowerShell 5.1 and PowerShell 7+Suggestions appear automatically after “command not found” errors

Use Cases

Installing Development Tools

When you need a tool you don’t have installed:
PS C:\> ffmpeg -version
# Suggestion: winget install Gyan.FFmpeg
PS C:\> winget install Gyan.FFmpeg
Common tools:
  • gitwinget install Git.Git
  • pythonwinget install Python.Python.3.12
  • nodewinget install OpenJS.NodeJS
  • dockerwinget install Docker.DockerDesktop
When following online tutorials that assume tool availability:
  1. Tutorial says: “Run kubectl get pods
  2. You type the command
  3. Command Not Found suggests: winget install Kubernetes.kubectl
  4. Install and continue tutorial
Running scripts written for Linux on Windows:
# Script calls 'curl'
PS C:\> curl https://api.example.com
# If not available: winget install cURL.cURL

Typo Correction

# Typo in command
PS C:\> gti status
gti : The term 'gti' is not recognized...

Suggestion: Did you mean 'git'?
  git is available at: C:\Program Files\Git\cmd\git.exe

Package Discovery

1

Try Command

Type a command you think should exist
PS C:\> terraform version
2

Get Suggestion

Command Not Found suggests package
Suggestion: winget install Hashicorp.Terraform
3

Install & Use

Install the package and run your command
PS C:\> winget install Hashicorp.Terraform
PS C:\> terraform version

Learning New Tools

Exploration

Try commands mentioned in documentation to see if they’re available

Package Names

Learn the official winget package IDs for tools

Alternatives

Discover alternative tools when suggestions show multiple options

Dependencies

Identify missing dependencies for complex software

Technical Details

Architecture

Database Integration

Command Not Found integrates with Windows Package Manager:
  • Package Index: Local cache of winget package data
  • Command Mapping: Database of commands to packages
  • Fuzzy Matching: Suggests similar commands for typos
  • Update Mechanism: Periodically refreshes package information

Module Interface

Minimal implementation for shell integration:
// Module interface implementation
// Location: src/modules/cmdNotFound/CmdNotFoundModuleInterface/

class CmdNotFoundModule : public PowertoyModuleIface
{
public:
    virtual void enable() override;
    virtual void disable() override;
    virtual bool is_enabled() override;
};
Source reference: src/modules/cmdNotFound/CmdNotFoundModuleInterface/dllmain.cpp

Shell Profile Modifications

When enabled, Command Not Found modifies shell profiles: PowerShell:
# Added to $PROFILE
Register-ArgumentCompleter -CommandName 'winget' -ScriptBlock {
    # Winget completion logic
}

# Command not found handler
$ExecutionContext.InvokeCommand.CommandNotFoundAction = {
    param($CommandName, $CommandLookupEventArgs)
    # Suggestion logic
}
Location: $PROFILE (typically ~\Documents\PowerShell\Microsoft.PowerShell_profile.ps1)

Troubleshooting

Check:
  • Command Not Found is enabled in PowerToys Settings
  • Terminal session started after enabling utility
  • PowerShell profile loaded correctly
Verify profile:
Test-Path $PROFILE
Get-Content $PROFILE | Select-String "CommandNotFoundAction"
Possible causes:
  • Outdated package database
  • Multiple packages provide same command
Solutions:
  1. Update winget: winget upgrade
  2. Check alternative packages: winget search <command>
  3. Refresh Command Not Found database (restart PowerToys)
Fix:
  1. Disable Command Not Found in PowerToys
  2. Restart PowerToys
  3. Re-enable Command Not Found
  4. Restart terminal sessions
This resets shell integration hooks
If you have other “command not found” handlers:
  1. Check PowerShell profile for conflicts
  2. Ensure Command Not Found handler runs last
  3. Consider disabling other handlers
Profile inspection:
code $PROFILE
# Look for multiple CommandNotFoundAction assignments

See Also