1

In Windows Vista,

Start->Run->cmd

opens cmd.exe

Where can I find a list of all the commands that can be executed there?

Today only I found out about getmac. I used to use ipconfig/all. getmac is so much more convenient.

1

8 Answers 8

4

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.

  1. For each directory in your PATH environment variable,
  2. 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!)

1
  • What an answer. Upvoted. :)
    – Alex
    Mar 13, 2010 at 8:59
6

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds.mspx?mfr=true should cover it

1

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)

3
  • Uh... I don't think that's what he meant by the second command you have there. Sep 30, 2009 at 22:02
  • The second command will list every executable file on c:! While certainly you can execute them, only ones on one's path are really relevant when asking "What can I run?" - regular executables should be a given.
    – Phoshi
    Sep 30, 2009 at 22:22
  • He asked, and I quote "a list of all the commands that can be executed there". I know I maybe took it too literally, but technically, that's the one :) Anyways, edit the answer if you feel like it. I won't mind.
    – Rook
    Sep 30, 2009 at 22:50
0

You can type "help" at the prompt and see most of the built in commands (plus some which are not built in, but are major ones).

That being said, there are a lot of "executables / batch / script" files such as anything ending in .exe, .com, .cmd.

However, I do not believe there is anyway of finding them all unless you just do a dir and pipe in all executables - however I doubt that would be effective.

0

Other commands here: http://ss64.com/nt/

0

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

0

I can scrape the list using Powershell (from https://ss64.com/nt/):

(invoke-WebRequest "https://ss64.com/nt/").AllElements | where-object {$_.tagName -eq "pre"} | select-object -Expand OuterText
0

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
...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .