Exec: Difference between revisions
Jump to navigation
Jump to search
Tip:The
Tip:
Warning:Recursive executions crash the game!
Example:If the CFG file
(Recursive exec crashes the game.) |
m (Removed duplicate sentence at the beginning of the article.) |
||
(11 intermediate revisions by 8 users not shown) | |||
Line 1: | Line 1: | ||
{{ | {{this is a|console command|name=exec}} | ||
It is used to execute [[.cfg]] files, namely a sequence of console commands. | |||
It is used to execute [[ | |||
== Usage == | == Usage == | ||
{{pre|exec <filename> [path id]}} | |||
The command executes the file <code>"//[path id]/cfg/<filename>"</code> if it exists. The default value of <code>[path id]</code> is <code>*</code>, resulting in the default path <code><game>/cfg/<filename></code>. | The command executes the file <code>"//[path id]/cfg/<filename>"</code> if it exists. The default value of <code>[path id]</code> is <code>*</code>, resulting in the default path <code><game>/cfg/<filename></code>. | ||
Line 12: | Line 11: | ||
{{tip|The <code>exec</code> command can be used in the [[launch options]] with <code>-exec <filename></code>, for example <code>-exec [[autoexec]]</code> will always execute the CFG file <code><game>/cfg/autoexec.cfg</code> when the game starts (which is overkill, because the game already executes autoexec.cfg even without this launch option).}} | {{tip|The <code>exec</code> command can be used in the [[launch options]] with <code>-exec <filename></code>, for example <code>-exec [[autoexec]]</code> will always execute the CFG file <code><game>/cfg/autoexec.cfg</code> when the game starts (which is overkill, because the game already executes autoexec.cfg even without this launch option).}} | ||
{{tip|<code>exec</code> can save a lot of time if a sequence of commands should be executed multiple times. Instead of typing the commands into the console every time, one can save them in a CFG file and execute it using <code>exec</code>.}} | {{tip|<code>exec</code> can save a lot of time if a sequence of commands should be executed multiple times. Instead of typing the commands into the console every time, one can save them in a CFG file and execute it using <code>exec</code>.}} | ||
{{warning|Recursive executions crash the game! {{ | {{warning|Recursive executions crash the game! {{ModernExample|If the CFG file <code><game>/cfg/keybinds.cfg</code> contains the line <code>exec keybinds</code>, then its execution will cause a game crash!}}}} | ||
== Examples == | == Examples == | ||
Line 51: | Line 50: | ||
| All [[console command]]s in the specified CFG file are executed with {{ent|whitelistcmd}}. Commands are ignored if they are not ''whitelisted'' in <code><game>/bspconvar_whitelist.txt</code>. | | All [[console command]]s in the specified CFG file are executed with {{ent|whitelistcmd}}. Commands are ignored if they are not ''whitelisted'' in <code><game>/bspconvar_whitelist.txt</code>. | ||
|} | |} | ||
Latest revision as of 11:58, 30 August 2025
exec
is a console command available in all Source games.
It is used to execute .cfg files, namely a sequence of console commands.
Usage
exec <filename> [path id]
The command executes the file "//[path id]/cfg/<filename>"
if it exists. The default value of [path id]
is *
, resulting in the default path <game>/cfg/<filename>
.
- The
<filename>
argument is the name of the file either with or without the .cfg extension. A path can also be prefixed. If the<filename>
argument is given, the game always prints the lineExecing config: <filename>
in the console. If the file does not exist, the game also prints the lineexec: couldn't exec <filename>
. - The optional
[path id]
argument can be used to specify a different path to execute CFG files from. Its first character must be*
.

exec
command can be used in the launch options with -exec <filename>
, for example -exec autoexec
will always execute the CFG file <game>/cfg/autoexec.cfg
when the game starts (which is overkill, because the game already executes autoexec.cfg even without this launch option).
exec
can save a lot of time if a sequence of commands should be executed multiple times. Instead of typing the commands into the console every time, one can save them in a CFG file and execute it using exec
.

<game>/cfg/keybinds.cfg
contains the line exec keybinds
, then its execution will cause a game crash!Examples
Command | Executed file |
---|---|
exec config
|
<game>/cfg/config.cfg
|
exec config.cfg
| |
exec config *
| |
exec config */maps
|
<game>/maps/cfg/config.cfg
|
exec folder/config
|
<game>/cfg/folder/config.cfg
|
exec folder/config */maps
|
<game>/maps/cfg/folder/config.cfg
|
Similar Commands
There are console commands that are identical to exec
, but with slight differences.
ConCommand | Availability | Description |
---|---|---|
execifexists
|
![]() ![]() ![]() ![]() ![]() ![]() |
There is no error message execifexists: couldn't exec <filename> in the console if the specified file does not exist.
|
execwithwhitelist
|
![]() |
All console commands in the specified CFG file are executed with whitelistcmd. Commands are ignored if they are not whitelisted in <game>/bspconvar_whitelist.txt .
|