Hi @Pedro
You are setting the environment variable as the user that runs the script, but it's a different user running the service.
Have a look here Run Metabase as a windows service!
You can Java use properties, so java -DMB_JETTY_PORT=3300 -jar metabase.jar
https://www.metabase.com/docs/latest/configuring-metabase/environment-variables