I am having trouble replicating this command from CMD
set APPDATA=D:\
.
The best equivalent I have is Set-Variable -Name $env:APPDATA -Value D:\
. This does not work!
The full script is:
set APPDATA=D:\
start java -jar D:\.minecraft\minecraft.jar
This sets it so Java looks in D:\
for .minecraft
instead of APPDATA
.
The full PowerShell version (which doesn't work right) is:
& Set-Variable -Name $env:APPDATA -Value D:\
& 'C:\Program Files\Java\jre1.8.0_66\bin\java.exe' -jar D:\.minecraft\Minecraft.jar
It still looks at the read-only version of $env:APPDATA
. I don't see why it can't be changed in the running environment for the shell's session, like cmd and most *nix shells!
I'm sure there are more uses for this than just running Minecraft. :P
Set-Variable
at all.Set-Variable
is for setting PowerShell variables, not for setting environment variables.Set-Variable
is not for environment variables in any of the answers, nor was it mentioned in the question. While the solution is similar, it is not a duplicate question.Set-Variable
, it's sad that the question how to set an env variable with PowerShell has already been asked several times, and we don't have a canonical Q to link to