Thanks to all. I found the answer and I share it for other people.
In the 3rd way, I put the absolute path for mysqldump:
$command1 = 'D:/xampp/mysql/bin/mysqldump --user=' . $dbUser . ' --password=' . $dbPassword . ' --host=' . $dbHost . ' ' . $dbName . ' > "' . $fnStorage . '"';
exec($command1, $output, $returnVar);
Now, it works for both design (VSCode) and production environments :)