Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
en:docs:cmd:file:ext [2014/05/24 09:40] – valerius | en:docs:cmd:file:ext [Unknown date] (current) – removed - external edit (Unknown date) 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== Executable Extensions ===== | ||
- | |||
- | The syntax for creating an executable extension is: | ||
- | |||
- | < | ||
- | set .ext=command [options] | ||
- | </ | ||
- | |||
- | This tells **CMD.EXE** to run the specified command whenever you name a file with the extension **.ext** at the prompt. | ||
- | |||
- | //.EXT// is the executable file extension; //command// is the name of the internal command, external program, alias, or batch file to run; and // | ||
- | |||
- | Normally, when you type a filename (as opposed to an alias or internal command name) as the first word on the command line, **CMD.EXE** looks for a file with that name to execute. The file's extension may be //.EXE// or //.COM// to indicate that it contains a program, it may have a batch file extension like //.BTM//, or the file's contents may indicate that it is executable. (To change the default list of extensions see the [[en: | ||
- | |||
- | You can add to the default list of extensions, and have **CMD.EXE** take the action you want with files that are not executable programs or batch files. The action taken is always based on the file's extension. For example, you could start your text editor whenever you type the name of a //.DOC// file, or start your database manager whenever you type the name of a //.DAT// file. | ||
- | |||
- | You can use environment variables to define the internal command, external program, batch file, or alias to run for each defined file extension. To create an executable extension, use the [[en: | ||
- | |||
- | For example, if you want to run a word processor called //EDITOR// whenever you type the name of a file that has an extension of //.EDT//, you could use this command: | ||
- | |||
- | < | ||
- | [c:\] set .edt=c: | ||
- | </ | ||
- | |||
- | If the command specified in an executable extension is a batch file or external program, **CMD.EXE** will search the [[en: | ||
- | |||
- | Once an executable extension is defined, any time you name a file with that extension the corresponding program, batch file, or alias is started, with the name of your file passed to it as a parameter. | ||
- | |||
- | The following example defines //B.EXE// (the Boxer text editor) as the processor for //.MAK// files: | ||
- | |||
- | < | ||
- | [c:\] set .mak=c: | ||
- | </ | ||
- | |||
- | With this definition, if you have a file named // | ||
- | |||
- | < | ||
- | [c:\source] init | ||
- | </ | ||
- | |||
- | **CMD.EXE** will execute the command: | ||
- | |||
- | < | ||
- | c: | ||
- | </ | ||
- | |||
- | Notice that the full pathname of // | ||
- | |||
- | < | ||
- | [c:\source] init -w | ||
- | </ | ||
- | |||
- | the command processor would execute the command: | ||
- | |||
- | < | ||
- | c: | ||
- | </ | ||
- | |||
- | In order for executable extensions to work, the command, program, batch file, or alias must be able to interpret the command line properly. For example, if a program you want to run doesn' | ||
- | |||
- | Executable extensions may include [[en: | ||
- | |||
- | The search for executable files starts in the current directory, then proceeds to each subdirectory specified by the [[en: | ||
- | |||
- | You may need to take this search order into account when using executable extensions. Using the //.MAK// example above, if you had a file named // | ||
- | |||
- | To remove an executable extension, use the [[en: | ||