Quick Tip # 7: nmap is not recognized as an internal or external command

You’ve downloaded Nmap for Windows, run the installer exe, elevated to your admin account for install, and opened a command prompt to run a scan.

As soon as you run an Nmap command, you receive the below error:

'nmap' is not recognized as an internal or external command, operable program or bath file.

This is common in environments where you are required to use a separate admin account for privilege escalation, during software installation for example, and a non-admin account for day-to-day use.

The reason for the error is that during the installation process, Nmap added the path of the Nmap executable directory to the installing user’s Environment Variables. We can see this if we open a PowerShell session as the installing user, and query the Environment Variables:

The PATH environment variable defines where the OS will look for executables. Any executables in the above paths will run within the shell without having to define the full path to the executable.

In comparison, your non-admin account is missing the Nmap path:

To add the path, search for “edit environment” in Windows search, and click ‘Edit environment variables for your account‘.

Highlight ‘Path‘ under ‘User variables for username‘, and click ‘Edit‘. In the ‘Edit Environment variable‘ window that pops up, click ‘New‘, and enter the full path of the Nmap install directory.

Click ok to all open dialog boxes, close all command prompt/PowerShell windows, and once relaunched, your Nmap command will run under the current user.

Leave a Reply

Your email address will not be published. Required fields are marked *