4

I see a lot of configurations for Source games(Valve games) using an autoexec.cfg file, and I wonder why it is used instead of the config.cfg that is already in the game folder of each Source game.

What is an autoexec.cfg file and what does it do?

Furthermore do I have any advantages using that instead of in-game consoles or config.cfg?

3 Answers 3

11

In short:

It is used because it preserves your configuration. If you edit the config.cfg or use the ingame console directly the settings will only stay until you closed the game.

First we need to clarify what happens when you start a source-engine game from steam.

At startup steam - if activated - loads a config from the cloud and checks back with the local config. After that the config is loaded into the game but not into the settings.

However if you change the settings via ingame menu - let's say controls for example - the config file will be rewritten from scratch.

That's why changing the config directly might work for one startup but will be reset after the game closes because the game rewrites the config too at this point.

Autoexec

Autoexec does execute commands and settings on startup after the cloud sync and rewrites the config. There is no autoexec.cfg file per default so it needs to be created in the same folder as config.cfg (For example DotA2: …\Steam\SteamApps\common\dota 2 beta\dota\cfg\, some games have it's cfg folder one directory up).

If you open the settings via ingame menu you will still see the old values because those consumerfriendly settings have higher priority resulting in another rewrite of the config. To circumvent this you need to unbind all keys from the ingame menu and set it once manually in the autoexec. This is not necessary for settings that have no binding at all like con_enable 1

However the autoexec itself is not touched by the source-engine, only read. So the config will be rewritten on every startup without the burden of changing the config itself every time.

Another note:

Using autoexec enables you to specify settings for your local machine that will not be overwritten if changed by another machine.

For example imaging changing the net_graph position for your laptop resolution. Without usage of autoexec it will be saved in the cloud and overwrite your desktop configuration forcing you to adjust the net_graph position to your 1920x1080 desktop resolution again.

If you use autoexec and start the game on the desktop resolution it will overwrite the net_graph position and adjust it for you since you defined it previously in the autoexec.

Example

// Net_graph positioning
net_graph "1"
net_graphinsetbottom "438"
net_graphinsetright "-80"
net_graphproportionalfont "0"

echo "autoexec loaded"

Lines with // will be ignored (comment). The remaining lines contain a command and a corresponding value. echo is a command to write any text (value here is "autoexec loaded") into the ingame console so you can see that your autoexec was loaded.

Furthermore if you changed your autoexec.cfg and you do not want to restart the game you can use the exec command like exec autoexec.cfg.

In fact you can exec any .cfg file but autoexec.cfg gets automatically loaded at startup.

Summary

Using autoexec.cfg is the safest way to control configurations in a source-engine game(valve) game and should be used especially for general settings like networking, graphics, etc

3
  • Where is the autoexec.cfg? I don't see one in any of my games. Do I have to make one somewhere and set it to read-only? Do I just put the lines I don't set in-game into it? Commented Jan 29, 2014 at 14:46
  • @Ullallulloo same folder as your config.cfg. you do not have to set it to read only. the source engine just does not write that file (thats what i meant. normal user have no clue that files have attributes like read-only) just put lines like the ones in config.cfg into it. for example con_enable "1" or net_graph "1". I will expand this answer later today because this is going to cover more then i expected.
    – Wandang
    Commented Jan 29, 2014 at 14:50
  • Some games have it (like garry's mod) in the SteamApps\common\[game]\[game/mod]\cfg folder.
    – 3ventic
    Commented Jan 29, 2014 at 14:53
0

Pretty sure that in a nutshell, autoexec automatically runs the commands you put into it in the console (rather than you typing them in every time you run the game). I'm not 100% sure, but I think that's how it works

1
  • While correct (if a little vague) there is already an answer which completely covers this. Generally it's only worth posting a new answer if you have something new to add, you believe the current answer is incorrect or you think it could be answered better.
    – DBS
    Commented Nov 15, 2015 at 0:14
-3

the current location of the autoexec.cfg should be: \steamapps\common\dota 2 beta\game\dota\cfg :Tested after the Reborn update:

3
  • This answer is not really bringing anything to the table. The location of the eautoexec.cfg file is the exact same as before the Reborn update, making this answer superfluous. Commented Sep 10, 2015 at 10:42
  • @piraten are you sure? I couldn't test it yet
    – Wandang
    Commented Sep 10, 2015 at 11:20
  • Am I sure that it's the same as before the Reborn update? Yes, based on this answer. I haven't been able to check for myself, but, like I mentioned this answer does not tell us anything that hasn't already been answered - see top answer for this question. Commented Sep 10, 2015 at 13:10

You must log in to answer this question.

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