To add a new location to your User Environment Path value string, (or create a new value if one did not already exist), for use in future cmd.exe sessions, but not in the current one, you could use something like this:
@Echo Off
Rem Please note: The Path variable stringtype is REG_EXPAND_SZ.
Rem This means it will auto expand contained variables within the location string.
Rem It is therefore recommended that you include those possible.
Rem But please be aware, when you include them below, double all percent characters.
Rem Enter your new User Path string entry here:
Set "NewString=%%SystemDrive%%\msys64\mingw64\bin"
Set "Reg=%SystemRoot%\System32\reg.exe"
Set "Key=HKCU\Environment"
Set "StX=%SystemRoot%\System32\setx.exe"
%Reg% Query "%Key%" /V Path 1>NUL 2>&1 && (For /F "EOL=H Tokens=2,*" %%G In ('
%Reg% Query %Key% /V Path 2^>NUL') Do %StX% Path "%NewString%;%%H" 1>NUL
) || %Stx% Path "%NewString%;" 1>NUL
For the current cmd.exe session only, you'd do it more like this:
@Echo Off
Path "C:\msys64\mingw64\bin;%Path%"
You could therefore, if you wish, append this as the next line in the upper script, to allow its use in the current instance, and for all future ones:
Path "%NewString%;%Path%"