Apathetic userprofile. Environment Variables - Environment variables. Step by step

Environment Variables, used in batch (command) files, allow you to avoid specifying absolute paths to directories. For example, if we do not know the system drive letter in advance, we can always use the variable %systemdrive%, which returns the drive letter on which the OS is installed. Also, variables are used to optimize code - a repeatedly repeated parameter (for example, a registry key) can be assigned a short variable and used. This article discusses in detail various techniques for working with variables, as well as ways to change and create new variables. Now let's talk about everything in order.

Classification of environment variables

Summary

The Windows command shell (cmd.exe) is a very powerful tool for working with the system. Batch files can automate a fair amount of tasks, which is why they are often used to automatic installation Windows. Skillful use of variables in batch files allows you to solve a wide range of issues. Working with the command shell becomes more efficient and at the same time the code for batch files is simplified. You can find other examples of using variables on the pages of the website or forum. All examples used in this article are taken from the scripts of the participants, for which many thanks to them.

Terminology

Command shell- this is separate software, which provides direct communication between the user and the operating system. Text user interface command line provides the environment in which applications run and utilities with a text interface.

cmd.exe- a command interpreter that the Windows OS command shell uses to translate the entered command into a format understandable to the system.

Team session can be initiated either by launch cmd.exe, and by running a batch file. In other words, the current command shell is created. Accordingly, exiting this shell (for example, finishing a batch file) ends the command session.

User session(user session) begins when the user logs in (log on) and ends when the user logs off (log off).

If the .USERPROFILE file is known to your system, then you can open it double click mouse or ENTER key. This operation will launch applications associated with the .USERPROFILE file installed on the system. If the system encounters a file for the first time and there are no corresponding associations, then the action will end with the system offering to find the corresponding software on a computer or the Internet.

Sometimes it happens that the wrong program is assigned to serve the .USERPROFILE file type. This happens due to the action of hostile programs such as viruses or malware, but most often this is the result of an erroneous combination of the application with the file extension .USERPROFILE. If, when servicing a new .USERPROFILE file type, we point the system to the wrong program, the system will erroneously recommend its use whenever a file of that type is encountered. In this case, you should try to select the appropriate application again. Right-click on the .USERPROFILE file, and then select from the menu the option "Open With..." and then "Choose default program". Now select one of the installed applications from the above list and try again.

Programs that will open the .USERPROFILE file

Manual editing of the Windows Registry

If our system cannot cope with the .USERPROFILE extension and all the automatic and semi-automatic methods of teaching it this art have failed, manual editing remains Windows registry. This registry stores all information relating to our work. operating system, including connecting file extensions to programs to serve them. Team REGEDIT inscribed in the window “search for programs and files” or "launch in the case of older versions of the operating system, it gives us access to the registry of our operating system. All operations performed in the registry (even not very complex ones regarding the .USERPROFILE file extension) have a significant impact on the operation of our system, so before making any modifications, you should make sure that a copy of the current registry is made. The section we are interested in is the key HKEY_CLASSES_ROOT. The following instructions show, step by step, how to modify the registry, specifically the registry entry containing information about the .USERPROFILE file.

Step by step

  • Click “start” button
  • In the “find programs and files” window (in older versions of Windows this is the “Run” window), enter the command “regedit” and then confirm the operation with the “ENTER” key. This operation will launch the system registry editor. This tool will not only allow you to view existing records, but also modify, add or remove them manually. Due to the fact that the Windows registry is key to its operation, all operations carried out on it should be performed judiciously and consciously. Carelessly removing or modifying an inappropriate key may permanently damage the operating system.
  • Using the ctr+F key combination or the Edit menu and the “Find” option, find the extension you are interested in.USERPROFILE by entering it in the search engine window. Confirm by pressing OK or using the ENTER key.
  • Backup copy. It is extremely important to create a backup copy of the registry before making any changes to it. Every change has an impact on the operation of our computer. In extreme cases, erroneous modification of the registry may result in the system being unable to restart.
  • The value you are interested in regarding the extension can be manually edited by changing the keys assigned to the found extension.USERPROFILE. In this place, you can also independently create the desired entry with the extension a.USERPROFILE if it is not in the registry. All available options are located in the handy menu (right mouse button) or in the "Edit" menu after placing the cursor in the appropriate place on the screen.
  • After you finish editing the entry for the .USERPROFILE extension, close the system registry. The introduced changes will take effect after restarting the operating system.

In the environment Windows Server everywhere - in the command line, scripts, etc. You can use environment variables, which provide an additional degree of freedom, since they allow you not to be tied to absolute values, replacing them with variables of a specific system. But, as practice has shown, many users are poorly versed in Environment Variables. This table is intended to provide guidance in everyday work with Windows Server environment variables.

List of Environment Variables

%ALLUSERSPROFILE% \Documents and Settings\All Users
%APPDATA% \Documents and Settings\(username)\Application Data
%CD% Returns the path to the current folder
%CMDCMDLINE% Returns the command string that was used to run this instance of Cmd.exe
%CMDEXTVERSION% Returns the version number of the current command processor extensions
%COMPUTERNAME% (computername)
%COMSPEC% \Windows\System32\cmd.exe
%DATE% Returns the current data. Uses the same format as the date /t command. Created by Cmd.exe command
%ERRORLEVEL% Returns the error code of the last command used. A value other than zero usually indicates an error.
%HOMEDRIVE% Disk with the user's home directory. Specified in the Local Users and Groups snap-in
%HOMEPATH% \Documents and Settings\(username) Specified in the Local Users and Groups snap-in
%HOMESHARE% The network path to the user's shared home directory. Specified in the Local Users and Groups snap-in
%LOGONSERVER% Returns the name of the domain controller that authenticated the current session
%NUMBER_OF_PROCESSORS% Specifies the number of processors installed on the computer
%OS% Returns the operating system name.
%PATH% C:\Windows\System32\,C:\Windows\,C:\Windows\System32\Wbem
%PATHEXT% Returns a list of file extensions that are considered executable by the operating system
%PATHEXT% .COM, .EXE, .BAT, .CMD, .VBS, .VBE, .JS, .WSF: .WSH (list executable files)
%PROCESSOR_ARCHITECTURE% Returns the processor architecture. Values: x86, IA64
%PROCESSOR_IDENTFIER% Returns a description of the processor
%PROCESSOR_LEVEL% Returns the model number of the processor installed on the computer
%PROCESSOR_REVISION% Returns the processor modification number
%PROGRAMFILES% \Program Files
%PROMPT% Returns command line options for the current Cmd.exe interpreter (usually $P$G)
%RANDOM% Returns an arbitrary decimal number from 0 to 32767. Created by the Cmd.exe command
%SYSTEMDRIVE% Returns the name of the drive containing the Windows root directory (i.e. the system directory)
%SYSTEMROOT% \Windows
%SYSTEMROOT% System returns the location of the Windows root directory.
%TEMP% and %TMP% :\DOCUME~1\(username)\LOCALS~1\Temp
%TIME% Returns the current time. Uses the same format as the time /t command. Created by Cmd.exe command
%USERDOMAIN% Returns the name of a domain containing a list of user accounts
%USERNAME% (username)
%USERPROFILE% \Documents and Settings\(username)
%USERPROFILE%\Application Data AppData
%USERPROFILE%\Cookies Cookies
%USERPROFILE%\Desktop Desktop
%USERPROFILE%\Favorites Favorites
%USERPROFILE%\Local Settings Local Settings
%USERPROFILE%\Local Settings\Application Data LocalAppData
%USERPROFILE%\Local Settings\History History
%USERPROFILE%\Local Settings\Temporary Internet Files Cache
%USERPROFILE%\My Documents My Documents
%USERPROFILE%\My Documents\My Music My Music
%USERPROFILE%\My Documents\My Pictures My Pictures
%USERPROFILE%\NetHood Nethood
%USERPROFILE%\PrintHood PrintHood
%USERPROFILE%\SendTo SendTo
%USERPROFILE%\Start Menu Start Menu
%USERPROFILE%\Start Menu\Programs Programs
%USERPROFILE%\Start Menu\Programs\Startup Startup
%USERPROFILE%\Templates Templates
%WINDIR% \Windows

Additionally, there are pseudo-variables in the popular file manager Total Commander:

Name Description Example
%$APPDATA% Application Data C:\Documents and Settings\MAIN\Application Data
%$DESKTOP% Desktop C:\Documents and Settings\MAIN\Desktop
%$PERSONAL% My Documents C:\Documents and Settings\MAIN\My Documents
%$PROGRAMS% Main menu\Programs C:\Documents and Settings\MAIN\Main Menu\Programs
%$STARTMENU% Main menu C:\Documents and Settings\MAIN\Main Menu
%$STARTUP% From:\Documents and Settings\MAIN\Main Menu\Programs\Startup
%$MYPICTURES% My drawings C:\Documents and Settings\MAIN\My Documents\My Pictures
%$MYMUSIC% My music C:\Documents and Settings\MAIN\My Documents\My Music
%$MYVIDEO% My video From:\Documents and Settings\MAIN\My Documents\My Video
%$LOCAL_APPDATA% Local Settings\Application Data C:\Documents and Settings\MAIN\Local Settings\Application Data
%$FONTS% Fonts C:\WINDOWS\Fonts

Windows environment variables - emphasis on “Y” in the second word (the meaning of the phrase is in the genitive case and the correct emphasis: variables of what? - environment!), in English-language Windows versions - environment variable)

Windows environment variables are used to configure operating systems. Not every user needs to understand these settings and get into these variables, but there are a couple of variables that all users need to be aware of personal computers. It's about about variables responsible for temporary storage of files - TEMP And TMP.



The default value of user temporary (TEMP) variables is %USERPROFILE%\Local Settings\Temp,

The default value of system temporary variables is \WINDOWS\Temp.

So in the first case it is usually: " C:\Documents and Settings\USER\Local Settings\Temp"

Inexpensive productive Ultrabook:

Specifications: 14.1 inch screen 1920*1080 ips, Windows 10, 8 GB RAM, 256 GB M.2 SATA 2280 SSD, Wifi, keyboard backlight.

Due to the fact that in the family of operating systems Windows folders For some reason, temporary files are not cleared by themselves; a huge variety of different files can accumulate in them unnecessary files, reaching a total size of up to several gigabytes! Various viruses and bad scripts periodically hide among temporary files, so it is the responsibility of every PC user to regularly delete the contents of temporary folders.

For ease of removal, it is better to change the default path to a simpler, most best option - "C:\Temp".

How to change Windows TEMP and TMP Environment Variables? - Very simple:

1. Right click on the " icon My computer" on the desktop (if it is a full-fledged icon and not a shortcut) or through the menu Start -> My Computer -> Properties:

2. Go to the "tab" Additionally" and click on the button below Environment Variables":

3. In the top window " User Environment Variables" first select the first line (TEMP variable) and press the button " Change":



4. Correct the variable value to a simpler one - " C:\Temp":

5. Repeat steps 3 and 4 for the variable TMP:

The result should be:

6. Press alternately 2 times " OK".



In principle, the same thing can be done using the command line by running the command: SET TEMP=C:\TEMP

All Windows environment variables:

ALLUSERSPROFILE Specifies the location of the All Users profile (local variable)
APPDATA Specifies the directory location where programs store data by default (local variable)
CD Specifies the name of the current directory (local variable)
CMDCMDLINE Indicates the command line options that were used to run the current instance of the CMD.EXE program (local variable)
CMDEXTVERSION Indicates the version number of the current shell extension (system variable)
COMPUTERNAME Specifies the computer name (system variable)
COMSPEC Specifies the exact path to the shell executable (system variable)
DATE Indicates the current date. The format is the same as for the date /t command. The value is generated by the shell (system variable)
ERRORLEVEL Indicates the error level code latest program. A non-zero value most likely indicates an error (system variable)
HOMEDRIVE Specifies the drive letter of the local workstation connected to the home directory. The variable is defined based on the path to the home directory. The user's home directory is determined in the Local Users and Groups snap-in (system variable)
HOMEPATH Specifies the full path to the user's home directory. The variable is defined based on the path to the home directory. The user's home directory is determined in the Local Users and Groups snap-in (system variable)
HOMESHARE Specifies the network path to the user's shared home directory. The variable is defined based on the path to the home directory. The user's home directory is assigned in the Local Users and Groups snap-in (system variable)
LOGONSERVER Specifies the name of the domain controller on which the current session with the system is authorized (local variable)
NUMBER_OF_PROCESSORS Indicates the number of processors installed in the computer (system variable)
OS Indicates the operating system version. Windows XP/XP operating systems are designated as Windows_NT (system variable)
PATH Specifies the search path for executable files (system variable)
PATHEXT Specifies a list of extensions that are recognized by the operating system as executable file extensions (system variable)
PROCESSOR_ARCHITECTURE Indicates the type of processor architecture. Possible values: x86 and IA64 (system variable)
PROCESSOR_IDENTIFIER Indicates processor description (system variable)
PROCESSOR_LEVEL Indicates the model number of the processor installed in the computer (system variable)
PROCESSOR_REVISION Indicates the processor model version number (system variable)
PROMPT Specifies the command line prompt options for the current interpreter. Generated by the CMD.EXE interpreter (local variable)
Random Specifies a random decimal number from 0 to 32767. Generated by CMD.EXE (system variable)
SYSTEMDRIVE Specifies the drive letter of the Windows root directory (system variable)
SYSTEMROOT Specifies the path to the Windows root directory (system variable)
TEMP or TMP Specifies the path to the default temporary directories. These directories are used by applications available to the user registered on the system. Some applications require the value of the TEMP variable, while others require TMP (system and user variables respectively)
TIME Indicates the current time. The format is the same as for the time /t command. Generated by the interpreter CMD.EXE (system variable)
USERDOMAIN Specifies the name of the domain where the Account user (local variable)
USERNAME Indicates the name of the user who is currently logged in to the system (local variable)
USERPROFILE Specifies the path to the current user's profile (local variable)
WINDIR Specifies the path to the operating system directory (system variable)



To access the value of a variable, you need to put a % sign before and after its name, for example: echo % NUMBER_OF_PROCESSORS%




Top