If you have powershell availible just invoke .net inside powershell to set the Environment it according to your needs.
[System.Environment]::SetEnvironmentVariable($Name, $Value, [System.EnvironmentVariableTarget]::Machine)
//[System.EnvironmentVariableTarget]::Machine
//[System.EnvironmentVariableTarget]::User
//[System.EnvironmentVariableTarget]::Process
See SetEnvironmentVariable documenation:
https://docs.microsoft.com/en-us/dotnet/api/system.environment.setenvironmentvariable?view=net-6.0
If you need to modify the a user environment under batch, I would change the registry.
See reg add documentaion:
https://docs.microsoft.com/de-de/windows-server/administration/windows-commands/reg-add
reg add HKEY_CURRENT_USER\Environment /v "TestTemp" /t REG_EXPAND_SZ /d "C:\temp"
Take care that the called process is a sub process of the parent and not a separate one, cause if the process call chain breaks all process environment variables are lost.
By the way the replacement of source command in powershell is different question.
See Microsoft documentation:
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_scripts?view=powershell-7.2
source key.sh
would be
. "key.ps1"
in PowerShell.
.bat
script runs in a child process (which does not transfer environment variables change to the parent one). Related: How can I source variables from a .bat file into a PowerShell script?.