Software-OK
≡... News | ... Home | ... FAQ | Impressum | Contact | Listed at | Thank you |

  
HOME ► Faq ► FAQ - Glossar ► ««« »»»

Environment Variables?


The Windows environment variables, are called configurable Windows variables in the operating system! 



For very often used paths of folders or specific directories of programs, as well as files that can be used by multiple programs.

Simply, this is a string ergo also a character intended to be wildcards for a specific directory or action.

With Windows there are still shell commands, with which one also has access to things that one does not even know, or knows that these exist on the Windows operating system. ►  A list of shell: directory commands! 

By the way, this will also be supported by other free file explorers for Windows and other programs.

Examples of Environment Variables!



%HOMEDRIVE% C:\
%PROGRAMFILES% Directory for installed programs 
%SYSTEMDRIVE% Windows Laufwerk auch C:\
%SYSTEMROOT% C:\Windows
%TEMP% or %TMP% The Windows temporary directory 
%WINDIR% Windows directory

etc .... . 



In the new Windows 10 and older Windows versions it is quite easily to list all Windows environment variables, by launching the Windows command prompt as an administrator and enter the SET command. The result is all standard Windows environment variables list for a specific operating system.

THE SET COMMAND 




ColorConsole [Version 2.5.1001 ] Microsoft Windows [Version 10.0.17134.112] (c) 2018 Microsoft Corporation. All rights reserved. C:\Users\Nenad\Desktop>SET /? Displays, sets, or removes cmd.exe environment variables. SET [variable=[string]] variable Specifies the environment-variable name. string Specifies a series of characters to assign to the variable. Type SET without parameters to display the current environment variables. If Command Extensions are enabled SET changes as follows: SET command invoked with just a variable name, no equal sign or value will display the value of all variables whose prefix matches the name given to the SET command. For example: SET P would display all variables that begin with the letter 'P' SET command will set the ERRORLEVEL to 1 if the variable name is not found in the current environment. SET command will not allow an equal sign to be part of the name of a variable. Two new switches have been added to the SET command: SET /A expression SET /P variable=[promptString] The /A switch specifies that the string to the right of the equal sign is a numerical expression that is evaluated. The expression evaluator is pretty simple and supports the following operations, in decreasing order of precedence: () - grouping ! ~ - - unary operators * / % - arithmetic operators + - - arithmetic operators << >> - logical shift & - bitwise and ^ - bitwise exclusive or | - bitwise or = *= /= %= += -= - assignment &= ^= |= <<= >>= , - expression separator If you use any of the logical or modulus operators, you will need to enclose the expression string in quotes. Any non-numeric strings in the expression are treated as environment variable names whose values are converted to numbers before using them. If an environment variable name is specified but is not defined in the current environment, then a value of zero is used. This allows you to do arithmetic with environment variable values without having to type all those % signs to get their values. If SET /A is executed from the command line outside of a command script, then it displays the final value of the expression. The assignment operator requires an environment variable name to the left of the assignment operator. Numeric values are decimal numbers, unless prefixed by 0x for hexadecimal numbers, and 0 for octal numbers. So 0x12 is the same as 18 is the same as 022. Please note that the octal notation can be confusing: 08 and 09 are not valid numbers because 8 and 9 are not valid octal digits. The /P switch allows you to set the value of a variable to a line of input entered by the user. Displays the specified promptString before reading the line of input. The promptString can be empty. Environment variable substitution has been enhanced as follows: %PATH:str1=str2% would expand the PATH environment variable, substituting each occurrence of "str1" in the expanded result with "str2". "str2" can be the empty string to effectively delete all occurrences of "str1" from the expanded output. "str1" can begin with an asterisk, in which case it will match everything from the beginning of the expanded output to the first occurrence of the remaining portion of str1. May also specify substrings for an expansion. %PATH:~10,5% would expand the PATH environment variable, and then use only the 5 characters that begin at the 11th (offset 10) character of the expanded result. If the length is not specified, then it defaults to the remainder of the variable value. If either number (offset or length) is negative, then the number used is the length of the environment variable value added to the offset or length specified. %PATH:~-10% would extract the last 10 characters of the PATH variable. %PATH:~0,-2% would extract all but the last 2 characters of the PATH variable. Finally, support for delayed environment variable expansion has been added. This support is always disabled by default, but may be enabled/disabled via the /V command line switch to CMD.EXE. See CMD /? Delayed environment variable expansion is useful for getting around the limitations of the current expansion which happens when a line of text is read, not when it is executed. The following example demonstrates the problem with immediate variable expansion: set VAR=before if "%VAR%" == "before" ( set VAR=after if "%VAR%" == "after" @echo If you see this, it worked ) would never display the message, since the %VAR% in BOTH IF statements is substituted when the first IF statement is read, since it logically includes the body of the IF, which is a compound statement. So the IF inside the compound statement is really comparing "before" with "after" which will never be equal. Similarly, the following example will not work as expected: set LIST= for %i in (*) do set LIST=%LIST% %i echo %LIST% in that it will NOT build up a list of files in the current directory, but instead will just set the LIST variable to the last file found. Again, this is because the %LIST% is expanded just once when the FOR statement is read, and at that time the LIST variable is empty. So the actual FOR loop we are executing is: for %i in (*) do set LIST= %i which just keeps setting LIST to the last file found. Delayed environment variable expansion allows you to use a different character (the exclamation mark) to expand environment variables at execution time. If delayed variable expansion is enabled, the above examples could be written as follows to work as intended: set VAR=before if "%VAR%" == "before" ( set VAR=after if "!VAR!" == "after" @echo If you see this, it worked ) set LIST= for %i in (*) do set LIST=!LIST! %i echo %LIST% If Command Extensions are enabled, then there are several dynamic environment variables that can be expanded but which don't show up in the list of variables displayed by SET. These variable values are computed dynamically each time the value of the variable is expanded. If the user explicitly defines a variable with one of these names, then that definition will override the dynamic one described below: %CD% - expands to the current directory string. %DATE% - expands to current date using same format as DATE command. %TIME% - expands to current time using same format as TIME command. %RANDOM% - expands to a random decimal number between 0 and 32767. %ERRORLEVEL% - expands to the current ERRORLEVEL value %CMDEXTVERSION% - expands to the current Command Processor Extensions version number. %CMDCMDLINE% - expands to the original command line that invoked the Command Processor. %HIGHESTNUMANODENUMBER% - expands to the highest NUMA node number on this machine. C:\Users\Nenad\Desktop>

EXAMPLE / OUTPUT  / SET


ColorConsole [Version 2.5.1001 ] Microsoft Windows [Version 10.0.17134.112] (c) 2018 Microsoft Corporation. All rights reserved. C:\Users\Nenad\Desktop>SET ALLUSERSPROFILE=C:\ProgramData APPDATA=C:\Users\Nenad\AppData\Roaming CommonProgramFiles=C:\Program Files (x86)\Common Files CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files CommonProgramW6432=C:\Program Files\Common Files COMPUTERNAME=DESKTOP-O5PRUUV ComSpec=C:\WINDOWS\system32\cmd.exe DriverData=C:\Windows\System32\Drivers\DriverData HOMEDRIVE=C: HOMEPATH=\Users\Nenad LOCALAPPDATA=C:\Users\Nenad\AppData\Local LOGONSERVER=\\DESKTOP-O5PRUUV NUMBER_OF_PROCESSORS=1 OneDrive=C:\Users\Nenad\OneDrive OS=Windows_NT PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC PROCESSOR_ARCHITECTURE=x86 PROCESSOR_ARCHITEW6432=AMD64 PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 58 Stepping 9, GenuineIntel PROCESSOR_LEVEL=6 PROCESSOR_REVISION=3a09 ProgramData=C:\ProgramData ProgramFiles=C:\Program Files (x86) ProgramFiles(x86)=C:\Program Files (x86) ProgramW6432=C:\Program Files PROMPT=$P$G PSModulePath=C:\Program PUBLIC=C:\Users\Public SystemDrive=C: SystemRoot=C:\WINDOWS TEMP=C:\Users\Nenad\AppData\Local\Temp TMP=C:\Users\Nenad\AppData\Local\Temp USERDOMAIN=DESKTOP-O5PRUUV USERDOMAIN_ROAMINGPROFILE=DESKTOP-O5PRUUV USERNAME=Nenad USERPROFILE=C:\Users\Nenad windir=C:\WINDOWS __COMPAT_LAYER=Installer .............
.............
.............
C:\Users\Nenad\Desktop>
 


FAQ 41: Updated on: 16 June 2018 13:42 Windows
Glossar

What is a pixel?


A pixel is the smallest object and the smallest component of a digital image. In the LCD monitor on the matrix are millions of pixels Pixel = Picture Element
Glossar

What is disk management?


Disk management is a tool to manage disk space, such as splitting into smaller parts called partitions or volumes Unlike the internal file manager MS-Explorer,
Glossar

What is it Printer queue?


If your printer is connected to your computer, whether locally or on the network, you may need to open the print queue. For example, to delete print jobs
Glossar

What is a cmd.exe?


Cmd.exe is the command line interpreter or command line interpreter for the Windows operating systems It is still part of the new Microsoft operating systems,
Glossar

What is a Windows document?


The solution is very easy to find on any Windows documents, or to open the default folder Content: 1. Windows documents folder open all OS 2.
Glossar

MEMORY.DMP file?


The MEMORY.DMP file, created on Windows Blue Screen, is a dump file, also known as crash dumps. These files contain a copy of the computers memory at the
Glossar

What is a file manager?


File managers allow users to manage files and folders. Delete, copy, move, such as the Windows Explorer in Windows 10 he is called File Explorer The Windows

»»

  My question is not there in the FAQ
Asked questions on this answer:
  1. Environment Variables from Windows?
  2. Environment variable not defined?
  3. Environment variables?
  4. What are environment variables?
  5. Which environment variables are there?
  6. What are environmental variables?
  7. What is the environmental variable?
Keywords: glossar, environment, variables, ask, question, answer, windows, configurable, operating, system, values, Questions, Answers, Software




    

  + Freeware
  + Order on the PC
  + File management
  + Automation
  + Office Tools
  + PC testing tools
  + Decoration and fun
  + Desktop-Clocks

  + SoftwareOK Pages
  + Micro Staff
  + Freeware-1
  + Freeware-2
  + Freeware-3
  + FAQ
  + Downloads

  + Top
  + Desktop-OK
  + The Quad Explorer
  + Don't Sleep
  + Win-Scan-2-PDF
  + Quick-Text-Past
  + Print Folder Tree
  + Find Same Images
  + Experience-Index-OK
  + Font-View-OK


  + Freeware
  + MagicMouseTrails
  + CpuFrequenz
  + MultiClipBoardSlots
  + OnlyStopWatch
  + KeepMouseSpeedOK
  + NonCompressibleFiles
  + 4ur-Windows-8-Mouse-Balls
  + 12-Ants
  + Q-Dir
  + PAD-s


Home | Thanks | Contact | Link me | FAQ | Windows 2021 | Windows 10 | English-AV | Impressum | Translate | PayPal | PAD-s

 © 2023 by Nenad Hrg softwareok.de • softwareok.com • softwareok.com • softwareok.eu
0.078


► Can I use the cute hearts in Microsoft Paint too! ◄

► How to create a batch file on / for MS Windows? ◄

► How to select/add users for Windows 8 / 10 / 11 Remote Desktop connections (allow, disallow, access authorization)? ◄

This website uses cookies to ensure you get the best experience on our website more Infos & Privacy Policy
....