Subject: Re: Location of Megatools INI Config File
From: Ondřej Jirman
Date: Mon, 8 Jun 2020 03:09:10 +0200

On Mon, Jun 08, 2020 at 01:51:38AM +0530, A. S. wrote:
> Hello Ondrej,
> Currently as per the docs the mega.ini config file is read either from the
> current directory or the user's home directory (except when
> --ignore-config-file is specified, or when an explicit path to the config
> file is given via --config <path>).
> First, what is considered the "home directory" under Windows?

So what home directory is on windows depends on bunch of things. Either

> Second, I am calling megatools from multiple batch files. The EXE itself as
> well as the mega.ini file is stored in a fixed dir (D:\Megatools), and I
> create batch files in different locations to download different types of
> files. Typically my batch files look like this:
> @set path=%path%;D:\Megatools
> megatools dl
> megatools dl
> Now suppose for example that a batch file like this is stored in and
> executed from E:\Downloads\Videos, unfortunately megatools doesn't read the
> mega.ini config file since neither does it exist in the current directory,
> nor in the "home directory" (whatever that is), nor has --config <path>
> been specified.
> I would like to have the config file read without making every megatools
> call in the batch file look like the following:
> megatools dl --config "D:\Megatools"
> So my request is, would it be possible to make megatools by default also
> look for its config file in the dir where its EXE is stored?
> Last but not least, since different mega.ini files may be stored in the
> current dir and home dir (and if you fulfil my request, the EXE's dir
> also), it would be nice if the tool initially printed out something like
> "Loaded config file <full path to mega.ini>" so that there's no confusion
> about which config file has been read.

Sorry, it's not that easy to determine exe file location in a cross-platform
way. Your best bet is to use --config=path to make sure the exact config file
is used no matter what.

Or set the HOME envvar prior to invoking megatools, but you have to make sure
there's not mega.ini in the current dir, and that there is one in the HOME/


> Thanks and Regards,
> Andrew