A post was split to a new topic: How to run a PHP script in the Magento 2 root directory with an access to the Magento 2 classes and database?