Vans Snow Slippers

Windows Environment Variables: Tips and Tricks

Windows 7/8/10: Environment Variables – what is it? The best tips

Environment variables make Windows everyday life easier for professionals: With these tips, you can start installed software faster with them. Another way to play is to delete ghost drivers. Environment variables start programs faster, save time when using the CMD and help with programming as well as removing Windows 7 ghost drivers. The term “environment variable” sounds abstract – and it is: even if you have never heard of it and don’t bother with it, your PC will run smoothly. Interventions in this regard are not necessary. However, they are practical: They make your everyday Windows life more comfortable in some respects. If you take a closer look at the variables, you will also learn more about how Windows works. First, you will find explanations about environment variables in this article. After that, you’ll get some practical tips to start your programs faster, invent your own command line commands and program them in batch. To spoil in advance what the variables do: They are short forms for PC actions to be done and save you time and effort (after familiarization and configuration). By the way, sometimes the variables are called “Environment Variables”: This is good to know if you want to get more information online. If you search the web with the English instead of the German term, you will find a bit more articles on the subject. The info in this text refers to Windows 7/8.1 and Windows 10 21H1 (May 2021 update). The tips probably apply to future Windows 10 versions as well. Recommended tools for environment variables: ” Speccy – displays installed variables under “Operating System > Environment Variables” ” SIW 2021 (trial version) – displays installed variables under “Environment” ” AIDA64 Extreme Edition (trial version) – see “Configuration > Environment Variables.” These power tools give Windows wings

What are environment variables?

Environment variables are placeholders suitable for typing into the Run dialog (press Windows-R) or the command line (press Windows-R, type cmd). The commands are shorter than those they represent. This saves you typing. If you remember the shorter counterparts, Windows makes the respective equivalents after pressing the Enter key. Among other things, %TMP% abbreviates the path C:\Users\\AppData\Local\Temp. Environment variables must be set in percent signs; typing, say, just “TMP” on a Run or CMD command line would result in an error message. Windows already has some environment variables installed; add your own if you wish. Probably their greatest advantage can be found in batch programming, the simplest form of software creation: Some folder paths differ from PC to PC because they contain an individually selected user name. Environment variables as command components of CMD or BAT batch files generalize here by directing to the correct folder, independent of the concrete user name: %TMP%, for example, is equivalent to %TEMP% and works on any Windows PC. On the article author’s machine, C:\users\sebastian\AppData\Local\Temp would also be useful (if the user name is Sebastian); if the account name is different on another user’s PC, this specific batch command is useless. An environment variable, on the other hand, always works and redirects to the correct destination in the file system. For example, you enter the variable command %TEMP% one-to-one in the Run dialog to open the Temp folder. In a command line it is necessary to prepend explorer; then %TEMP% serves as a parameter to specify the directory call via file manager. Otherwise %TEMP% is also suitable for input in command line windows without the explorer part: In this case, however, you do not open a folder, but insert the corresponding path. In itself, however, the path is useless because it does not represent a CMD command: Therefore, an error message like “The command ‘C:\Users\SEBAST~1\AppData\Local\Temp’ is either misspelled or could not be found” appears. However, if you prepend the batch command echo (echo %TEMP%), you will see the resolved path in the CMD. Also with preceding cd (for change directory, change directory), you work with the %TMP% variable in a meaningful way; as a result, your console commands in this CMD session affect the temp folder. Opening the Windows folder with the temp files works laboriously the traditional way (long command and long click path). Or you can use a variable.

Environment variables: View list, create your own

To access a list of environment variables available in Windows, press Windows-R and type sysdm.cpl, switch to the Advanced tab and click Environment Variables. Alternatively, you can get to the Advanced tab directly with the Win-R command systemPropertiesAdvanced. In the new window you will find user variables at the top and system variables at the bottom. The user variables have their equivalent in the registry in the key HKEY_CURRENT_USER\Environment. If you add a new variable in the environment variables dialog by clicking on the upper “New” and confirm, it appears in the HKCU\Environment key as a string entry (REG_SZ). System variables are mapped by the Windows Registry in the following key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment. If you want to view the variables via command line, press Windows-R and type cmd: Then execute the set command. It is also recommended to have a look at the clearer list of windows-commandline. The creation of variables is not only possible graphically, but also via command line. Enter setx including parameters: e.g. setx wordpad C:\Windows\write.exe Replace wordpad with the desired variable name and the path behind it with the one you want to access. In the example, you will start the same-named on-board writing program by entering %wordpad% in the Run dialog. In this dialog of the system properties you can see your environment variables.

Create your own Run dialog commands

If you frequently press Win-R and enter Run dialog commands to access programs, on-board tools, files and folders more quickly, you may want to install your own commands. Among other things, this is possible via environment variables. Details and alternatives can be found in the article “Windows 7/8/10: Creating your own run commands – here’s how to do it”. The newly created own commands are to be set in % characters in the Win-R window. If, on the other hand, you establish your own Win-R commands via the registry key “App Paths” (instructions can be found in the article linked above), the auxiliary characters are omitted.

Install new CMD shortcuts

From the Run dialog, use the firefox or iexplore command to start the Firefox or Internet Explorer browser, respectively. This works because of a registry appaths key including EXE path in the registry of these programs. Via the command line you do not call the applications with the commands. If you want to change this, add one environment variable each: Select the upper button “New” in the sysdm.cpl window and enter firefox or iexplore in “Value of variable”. In the lower field enter the EXE call path to the desired browser, quotation marks are necessary because of the spaces in the path. The locations are “C:\Program Files (x86)\Internet Explorer\iexplore.exe” and “C:\Program Files\Mozilla Firefox\firefox.exe”. Don’t forget to add % to the call commands in the command line, so they are %iexplore% and %firefox%. To add your own system variables, fill in the fields in the small window.

Start several programs at the same time

If you assign several commands to a variable that it should execute, you can later start different programs in one go with only one command. For example, create a variable diesdas and assign the call command appwiz.cpl&cleanmgr&dfrgui. If you now enter %thisthis% in a command line, three on-board tools for system optimization are started: the uninstallation management (appwiz.cpl), the disk cleanup (cleanmgr) and the defragmentation (dfrgui). In the Win-R dialog, the %this% command does not work; if you want to run it here, prepend cmd /k – so that the Run dialog command is cmd /k %this%.

Windows 7: Uninstall ghost drivers

The Device Manager (accessed with Windows-R and devmgmt.msc) shows you USB sticks that are connected to the PC and allows you to uninstall their drivers. Devices that are currently not connected to the PC can be seen after clicking on “View > Show hidden devices” (checkmark). In Windows 7, this click sequence has no effect; since Windows 8, this bug has been fixed. If Windows 7 users want to list driver entries of unconnected peripherals, a detour is necessary: You start a command line with admin rights via Start menu search for cmd and with Ctrl-Shift input, enter set devmgr_show_nonpresent_devices=1 and then devmgmt.msc. Now setting the check mark does something. The preliminary work has to be repeated for each devmgmt.msc call. The effort is not necessary if you create an environment variable (the steps can be found in the ghost driver guide). A specific environment variable effectively serves as a bug fix for the Windows 7 Device Manager.

Check environment variables for existence (CMD)

Use the command line set to check if an environment variable exists. It is sufficient to type its name incompletely. If the entry exists, the complete variable name appears after pressing the Enter key. Behind it the console indicates what the variable calls. If the autocompletion fails, the error message “The environment variable “” is not defined” appears.

Query environment variable via reg query (batch)

A tip for professionals: Are you a batch programmer and do you want to use a script to query whether an environment variable exists? You can do this with the following code (replace the part “firefox” with the variable you want to check): @echo off reg query HKCU\Environment /v firefox > NUL 2>NUL if %errorlevel%==0 echo Exists if %errorlevel%==1 echo Does not exist pause Use the Windows editor notepad.exe to create a BAT or CMD file with the above five lines. Double click on the file to make the command line load it. Depending on whether the variable exists, “echo” will display the message “Exists” or “Does not exist”. Alternatively, instead of using “echo”, use goto to trigger an (echo) action using a jump label, depending on the variable’s existence. Vans Snow Slippers.




Leave a comment

Your email address will not be published. Required fields are marked *