Created
September 13, 2023 19:24
-
-
Save alvonx/1ca1de58ace37eaa1a7ec6c13dac3a52 to your computer and use it in GitHub Desktop.
get and set environment variable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
:: Define the name and value of the environment variable | |
set "MY_VARIABLE=MY_VALUE" | |
:: Set the environment variable using setx | |
setx MY_VARIABLE "%MY_VARIABLE%" | |
:: Display a message indicating that the variable has been set | |
echo Environment variable MY_VARIABLE set to %MY_VARIABLE% | |
:: Delay for 10 seconds (you can adjust the duration as needed) | |
timeout /t 10 | |
@echo off | |
:: Get the value of the environment variable | |
set "MyVariableValue=%MY_VARIABLE%" | |
:: Display the value of the environment variable | |
echo The value of MY_VARIABLE is: %MyVariableValue% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment