Under WSH (Windows Script Host), you can access the COM object WScript.Shell for some useful functions. For example, the collection Environment provides the environment variables, so you can easily use either JScript or VBScript to access some particular information.

this seems to be same as setting the environment-variable in windows. Is this the only way of using local-variables in batch scripts? – parasrish Jun 16 '16 at 9:01. 1 @Wolf, you only have to ensure that the command extensions are enabled, but this is the default configuration anyway Windows Environment Variables - Windows CMD - SS64.com How-to: Windows Environment Variables. Environment variables are mainly used within batch files, they can be created, modified and deleted for a session using the SET command. To make permanent changes, use SETX Variables can be displayed using either SET or ECHO.. Variables have a percent sign on both sides: %ThisIsAVariable% The variable name can include spaces, punctuation and mixed case How to Set Environment Variables in Windows 10 May 14, 2020

Pass variables between batch scripts There are several ways to pass values between batch files, or between a batch file and the command line, see the CALLand SETLOCALpages for full details.

All of this works because you can actually create variables that are code, and use them inside of other commands. It is sort of like a ghetto function, since batch is not exactly the most advanced of shell scripting languages. This only works because batch's poor usage of variables, not designating between ints, chars, floats, strings, etc

Batch file - Wikipedia

List of All Environment Variables in Windows 10 Mar 18, 2019 Can a script.bat make changes to Windows PATH Environment