It depends a little bit on the language your script is written in.
If bash, simply set them in the script via export. If another language, then you’ll need to use a different syntax; the first solution you linked was for powershell.
Either way, they’re just regular environment variables, nothing specific to restic. That’s why the restic docs don’t really explain how to set them.
Environment variables are something that is a basic feature of operating systems and hence not something we can elaborate on the basics of in the restic manual. You can check Environment variable - Wikipedia for more information.
I understand. I consulted you because I asked a similar question before and also here they answered that if a user or someone already has access or the computer with the data, the other security measures would be secondary (minus cloud or offline backup) which makes sense.