Home » Questions » Computers [ Ask a new question ]

Where can I find a list of commands that can be executed from cmd.exe?

Where can I find a list of commands that can be executed from cmd.exe?

In Windows Vista,

Asked by: Guest | Views: 345
Total answers/comments: 5
Guest [Entry]

"As others have pointed out, ""dir *.exe /s"" will find you all the EXEs on the drive, and assuming you have permissions to do so, you can execute all of them directly (so long as you include an absolute path).

And the ""help"" command gives you a listing of basic MS built-ins.

But assuming you want a real answer, of a) a list of actual commands that b) you don't need full pathnames to run and c) include everything on YOUR system, not just Microsoft's tools, you need to discover it programmatically.

I don't know how to do this in DOS (or CMD), but I can give you the steps.

For each directory in your PATH environment variable,
list all files ending in the extensions listed in the PATHEXT environment variable.

When you type a command, PATH is a list of locations where Windows looks for that command, and PATHEXT is a list of file extensions it will append to that command to match to a file. Both are semicolon-separated lists, and both are searched in order. Here's my system:

PATH=c:\WINDOWS\system32;c:\WINDOWS;C:\cygwin\usr\local\bin;C:\cygwin\bin;C:\cygwin\bin;c:\Perl\bin\;c:\Python24;c:\Python24\bin;c:\WINDOWS\System32\Wbem;c:\Program Files\Common Files\GTK\2.0\bin;c:\bin
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH

You can probably guess I've made some modifications to my system PATH; yours will probably be less cluttered. (Or not; QuickTime and Java can't be the only programs that insist they need to add themselves to my path, so yours probably has some unexpected additions too.)

When I execute, say,

C:\> findstr

.. Windows searches each entry in the PATH variable for a file named ""findstr"" (case insensitive). It doesn't find that file in the first entry, so it checks for all possible permutations, by appending the extensions listed in PATHEXT to the command name and checking for that file. First it checks for ""C:\WINDOWS\system32\findstr.com"", but there's no such file. Next it checks ""C:\WINDOWS\system32\findstr.exe"" and finds it, so that's the program it runs.

Hopefully I wasn't trying to run ""C:\WINDOWS\system32\findstr.bat"" or ""C:\bin\findstr.com"" -- those files would have been run had I run one of these:

C:\> findstr.bat
C:\> findstr.com

... but since I only typed ""findstr"", I got the .EXE version.

So that's how Windows runs your commands on the commandline. If you want the full list of words you can type there and have run, you'll need to check your own PATH variable for where to look, and your own PATHEXT variable for what extensions to look for.

C:\> set | findstr PATH
PATH=C:\...
PATHEXT=...

(If anyone else wants to chime in with a succinct DOS commandline that will automate this, please weigh in!)"
Guest [Entry]

"In Windows Vista, Start->Run->cmd opens cmd.exe.
Where can I find a list of all the commands that can be executed there?

Typing

help

in the command prompt will give you a survey of the cmd commands, most left from the dos days. However, to get a list of everything that can be started from a cmd prompt (which is .exe, .com, .bat, .cmd and various executable files, like .pyc and so on, you'd have to do

c:\> dir *.exe,*.com,*.bat,*... /s

(this will also get you some browser cookies ending in .com, so ignore those)"
Guest [Entry]

"Along with the help or /? after a command in question is prefer this site

http://commandwindows.com/vista-commands.htm

not only does it list all of them but you can click on the to get the sub commands for each and how its used"
Guest [Entry]

"I can scrape the list using Powershell (from ss64.com/nt/):
(invoke-WebRequest ""ss64.com/nt/"").AllElements | where-object {$_.tagName -eq ""pre""} | select-object -Expand OuterText"
Guest [Entry]

"Building on quack quixote's answer, I made a batch file to dump the list for you.
@ECHO OFF

:: Delete any old log
set logName=ListCmdPrograms.log
del %logName% > nul

:: Start the recursive function
call :parsePath ""%path%""

:: Cleanup
echo.
echo.
pause
goto :eof

:: Loop through all the folders in the PATH variable
:parsePath
setlocal
set folders=%~1
for /F ""tokens=1* delims=;"" %%a in (""%folders%"") do (
if not ""%%a"" == """" call :searchPath ""%%a""
if not ""%%b"" == """" call :parsePath ""%%b""
)
endlocal
goto :eof

:: Search a folder found in the PATH variable
:searchPath
setlocal
echo %~1 >> %logName%
call :findExts ""%~1"", ""%pathext%""
echo. >> %logName%
endlocal
goto :eof

:: Loop through all the extensions in the PATHEXT variable
:findExts
setlocal
set folder=%~1
set exts=%~2
for /F ""tokens=1* delims=;"" %%c in (""%exts%"") do (
if not [""%%c""] EQU [""""] call :exportFindings ""%folder%"", ""%%c""
if not [""%%d""] EQU [""""] call :findExts ""%folder%"", ""%%d""
)
endlocal
goto :eof

:: Search for an extension found in the PATHEXT variable
:exportFindings
setlocal
set folder=%~1
set ext=%~2
if NOT [%folder:~-1%] EQU [\] set folder=%folder%\
echo %folder%*%ext%
dir /b %folder%*%ext% >> %logName%
endlocal
goto :eof

It output a log file in the same folder as the batch file with results that look like this:
C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\ia32\mpirt

C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\ia32\compiler

C:\Windows\system32
chcp.com
format.com
mode.com
more.com
tree.com
AcSignOpt.exe
agentactivationruntimestarter.exe
AgentService.exe
...
taskschd.msc
tpm.msc
WF.msc
WmiMgmt.msc

C:\Windows
bfsvc.exe
explorer.exe
HelpPane.exe
..."