To set a temporary or 'per session' environment varible from a command line you can use:

set ‹var name›=‹value>

Make sure your spacing is exactly as shown above, if you add a space between the equal sign the command will fail.

Check: Link for a nice tutorial and info on environment variables.

Answer from akseli on Stack Exchange
🌐
Microsoft Learn
learn.microsoft.com › en-us › windows-server › administration › windows-commands › set_1
set (environment variable) - Windows commands
If you use the set command without any parameters, the current environment settings are displayed. These settings usually include the COMSPEC and PATH environment variables, which are used to help find programs on disk. Two other environment variables used by Windows are PROMPT and DIRCMD.
Discussions

command line - Set Environment Variables Windows - Stack Overflow
First off, I'd like to apologise if this has already been covered. It's difficult to filter through all the existing issues similar to this one. So in Windows there is two (as far as I'm aware) wa... More on stackoverflow.com
🌐 stackoverflow.com
Environment Variable Setting via Command Line
Is there a command line I can use to set PC and Server environment variables? I have several I have to type in often. It would be nice to write a script to enter them for me. More on community.spiceworks.com
🌐 community.spiceworks.com
3
6
July 28, 2022
How do I set Windows environment variables permanently? - Stack Overflow
How do I set Windows environment variables permanently? I see that the Windows environment variables are reset when you close the command window. I want to set them permanently, so that I don't hav... More on stackoverflow.com
🌐 stackoverflow.com
Standard users How Do you set Enviroment variables
User variables can only be used ... are set, system variables are shared for all users. The user can use his/her user variables + the system variables. ... Hi Roman and Thank you. So I have to log in as Admin to access to System variables. Ok . Waht's the pourpos of the User Variables ? Does it only work until you restart windows? ... I think your problem is not caused by the environment ... More on learn.microsoft.com
🌐 learn.microsoft.com
11
0
December 28, 2019
🌐
Progress
docs.progress.com › bundle › openedge-sql-development › page › Set-environment-variables-in-Windows.html
Set environment variables in Windows
Work from the Settings menu of your Windows environment to set your JDBC driver environment variables. To set the environment variable in Windows: Select Start > Settings > Control Panel > System . The System Properties window appears. Select the
🌐
Twilio
twilio.com › en-us › blog › how-to-set-environment-variables-html
How to Set Environment Variables | Twilio
December 9, 2025 - New-Item -Path Env:\TWILIO_ACCOUNT_SID -Value '<YOUR_ACCOUNT_SID>' [Environment]::SetEnvironmentVariable('TWILIO_ACCOUNT_SID', '<YOUR_ACCOUNT_SID>') [Environment]::SetEnvironmentVariable('TWILIO_ACCOUNT_SID', '<YOUR_ACCOUNT_SID>', 'Process') To persist environment variables across shell instances, you can save the cmdlets into your profile script, or on Windows, you can save them in the user registry or machine registry like this:
🌐
Autodesk
autodesk.com › support › technical › article › caas › sfdcarticles › sfdcarticles › How-to-set-an-environment-variable.html
How to set an environment variable
How to set an environment variable in different Operative Systems How to Set Environment Variables in macOS , Windows , and Linux. For macOS terminal based programs macOS Mojave (10.14) or earlier (bash is the default shell). Permanent environment variable in bash for the current user: Edit ...
Find elsewhere
🌐
NTU Singapore
www3.ntu.edu.sg › home › ehchua › programming › howto › Environment_Variables.html
Environment Variables in Windows/macOS/Linux
Environment Variables in Windows are NOT case-sensitive (because the legacy DOS is NOT case-sensitive). They are typically named in uppercase, with words joined with underscore (_), e.g., JAVA_HOME. To list ALL the environment variables and their values, start a CMD and issue the command "set", as ...
🌐
GitHub
gist.github.com › mitchmindtree › 92c8e37fa80c8dddee5b94fc88d1288b
How to permanently set user environment variables on Windows · GitHub
Here are three ways you can set the user environment variable FOO with the value path\to\foo so that the variable persists across sessions. ... [Environment]::SetEnvironmentVariable("FOO", "path\to\foo", [System.EnvironmentVariableTarget]::User) Using the windows GUI.
🌐
Oracle
java.com › en › download › help › path.html
How do I set or change the PATH system variable?
Making changes to the system PATH variable is typically not necessary for computers running Windows or Mac OS X. In Search, search for and then select: System (Control Panel) Click the Advanced system settings link. Click Environment Variables. In the section System Variables find the PATH ...
🌐
MiniTool Partition Wizard
partitionwizard.com › home › news › a full guide to environment variables set and edit on windows 11
How to Set and Edit Environment Variables on Windows 11
January 16, 2026 - Learn how to set and edit environment variables on Windows 11. This post covers the definition, types, and methods to create, set, and edit.
🌐
Microsoft Learn
learn.microsoft.com › en-us › windows › win32 › api › winbase › nf-winbase-setenvironmentvariable
SetEnvironmentVariable function (winbase.h) - Win32 apps | Microsoft Learn
September 22, 2022 - BOOL SetEnvironmentVariable( [in] LPCTSTR lpName, [in, optional] LPCTSTR lpValue ); ... The name of the environment variable. The operating system creates the environment variable if it does not exist and lpValue is not NULL.
🌐
PyPI
pypi.org › project › python-dotenv
python-dotenv · PyPI
To help you with that, you can add python-dotenv to your application to make it load the configuration from a .env file when it is present (e.g. in development) while remaining configurable via the environment: from dotenv import load_dotenv load_dotenv() # reads variables from a .env file and sets them in os.environ # Code of your application, which uses environment variables (e.g.
      » pip install python-dotenv
    
Published   Mar 01, 2026
Version   1.2.2
🌐
Eleven Forum
elevenforum.com › windows support forums › tutorials
Create New Environment Variables in Windows 11 | Windows 11 Forum
November 20, 2024 - Substitute [variable name] in the command above with the actual variable name (ex: "Downloads") you want used as the environment variable (ex: "%Downloads%" or "$Env:Downloads"). Substitute [variable value] in the command above with the actual variable value (ex: "C:\Users\Brink\Downloads") you want referenced by the environment variable. For example: [Environment]::SetEnvironmentVariable("Downloads","C:\Users\Brink\Downloads","User") 3 You can now close Windows Terminal if you like.
🌐
Google AI
ai.google.dev › generatecontent api › using gemini api keys
Using Gemini API keys | Google AI for Developers
3 weeks ago - Search for "Environment Variables" in the search bar. Choose to modify System Settings.
🌐
Atlassian
imatest.atlassian.net › wiki › spaces › KB › pages › 12049809418 › Editing+System+Environment+Variables
Editing System Environment Variables - Knowledge Base - Imatest
October 11, 2024 - If the property is a plain text value, type in the variable value (and name, if it is a new variable). Click OK on each of the windows to save the changes. Note, for some properties, you may need to restart your computer before the changes take effect. To permanently set an environment variable ...
🌐
PhoenixNAP
phoenixnap.com › home › kb › sysadmin › how to set environment variable in windows
How to Set Environment Variables in Windows
December 9, 2025 - The method for checking current environment variables depends on whether you are using the Command Prompt or Windows PowerShell: In the Command Prompt, use the following command to list all environment variables: ... Both the Command Prompt and PowerShell use the echo command to list specific environment variables. ... Here, [variable_name] is the name of the environment variable you want to check. Follow the steps to set environment variables using the Windows GUI:
🌐
Microsoft Learn
learn.microsoft.com › en-us › answers › questions › 3243422 › standard-users-how-do-you-set-enviroment-variables
Standard users How Do you set Enviroment variables - Microsoft Q&A
December 28, 2019 - I've tryed to restart windows explorer or OS but with no success. It works randomly. Sometimes when I set the value through the control panel it works , sometimes it doesn't · and I always double check the folder path/name or debug it writing echo %var1% etcc... The real problem it happens randomly. I suspect it only happens with standard user account ... I made a second video: here I just open Panel ,move the %var% and close. It works ! ... Environmental variables that you set in a Command Prompt are only valid during that session.