0

In my school to use CMD you have to run it via command.com

When I do this and use the command "help" it will open the batch file help instead of displaying the help command.

Just out of interest, is there anyway to get past this other than moving or renaming the file?

Gareth Jones
  • 1,241
  • 4
  • 17
  • 38

2 Answers2

1

Maybe you could specify the absolute path to the help command you want.

BillRobertson42
  • 12,602
  • 4
  • 40
  • 57
  • Thats the thing, whats the help command called? Is it help.com? If you just have "Help" it wont work, it will find Help.cmd. If you use "Help.com" it will say its not a recognized as an inter.... ect – Gareth Jones Nov 02 '11 at 22:42
  • @GarethJones: You may know the name of the command. See my answer – Aacini Nov 03 '11 at 00:07
  • Its help.exe, and is probably located at c:\windows\system32\help.exe. The other thing you could do, is call help.exe and that should skip your script and just call the right program. That script above is pretty cool though, never thought to try something with windows bat/cmd file. – BillRobertson42 Nov 04 '11 at 00:38
1

You may know the full path name (with extension) of the executable file with the Batch file below (I call it PATHOF.BAT):

@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
REM CREATE A LIST OF FILE NAMES ADDING THE EXECUTABLE EXTENSIONS
SET NAMEEXT=!PATHEXT:.=%1.!
REM SEARCHES FILE NAMES IN CURRENT DIRECTORY, IF FOUND: ERRORLEVEL=1
FOR %%N IN (%NAMEEXT%) DO IF EXIST %%N ECHO %%N & EXIT /B 1
REM SEARCHES FILE NAMES IN DIRECTORIES OF PATH VARIABLE, IF FOUND: ERRORLEVEL=2
FOR %%N IN (%NAMEEXT%) DO IF NOT "%%~$PATH:N" == "" ECHO %%~$PATH:N & EXIT /B 2
REM IF FILE NOT FOUND, ERRORLEVEL=0
ECHO '%1' is not an external command or batch file located in PATH & EXIT /B 0

For example: pathof help

Aacini
  • 65,180
  • 12
  • 72
  • 108