### What changes were proposed in this pull request?
This PR is basically a followup of SPARK-26132 and SPARK-32434. You can't define an environment variable within an-if to use it within the block. See also https://superuser.com/questions/78496/variables-in-batch-file-not-being-set-when-inside-if
### Why are the changes needed?
For Windows users to use Spark and fix the build in AppVeyor.
### Does this PR introduce _any_ user-facing change?
No, it's only in unreleased branches.
### How was this patch tested?
Manually tested on a local Windows machine, and AppVeyor build at https://github.com/HyukjinKwon/spark/pull/13. See https://ci.appveyor.com/project/HyukjinKwon/spark/builds/34316409Closes#29254 from HyukjinKwon/SPARK-32434.
Authored-by: HyukjinKwon <gurwls223@apache.org>
Signed-off-by: HyukjinKwon <gurwls223@apache.org>