settings.json/steam_appid.txt/etc placed in working directory instead of the application folder #223
Labels
Status: Implemented
Indicates that the issue has been handled but may not have been merged.
Type: Enhancement
Milestone
Hi!
Expected Behavior
The instance-specific configuration (everything except GlobalSettings) is tied to that copy/extracted directory of AML without being affected by how AML is started.
Current Behavior
AML searches for its configuration in the current working dir of the calling environment.
Possible Solution
During startup, set the working dir to the directory containing the executable:
XCOM2 Launcher.exe
(Or use appropriate paths when opening settings.json/etc, but I reckon that is more effort.)
Steps to Reproduce
cd C:\
.\path\to\XCOM2 Launcher.exe
Details / Context
Some application launchers behave differently than Windows Shell/Explorer.
For example: PowerToys Run uses its own installation directory as the working dir for applications it starts (which I admit is questionable). As a result, AML tries to write to
C:\Program Files\PowerToys\steam_appid.txt
, which is neither sensible, nor likely to succeed, unless elevated.Possible Implementation
Directory.SetCurrentDirectory(Path.GetDirectoryName(Application.ExecutablePath));
on startupI'm not too knowledgeable on C#/WinForms so there might be a more fitting API to use, but this does do the trick; tested locally.
Behaviour when double-clicking the executable or using Run (win+r) is unchanged, as this change simply forces a behaviour that was already present in those scenarios. Behaviour when using a Shortcut to launch AML is unchanged as well, unless the user manually changed the
Start in
attribute of the shortcut.All this is under the assumption that keeping the settings in the application dir is indeed the intended behaviour. Please correct me if I'm wrong on this.
I can do a pull request for this, but given that it's a one-liner, it might be easier for a contributor to make the change directly.
Greetings,
antiz
The text was updated successfully, but these errors were encountered: