198

What is the difference between user variables such as PATH, TMP, etc. and system variables?

I accidentally deleted the user variable PATH. What am I supposed to do?

RamenChef
  • 5,557
  • 11
  • 31
  • 43
rookie
  • 7,723
  • 15
  • 49
  • 59

5 Answers5

156

Right-click My Computer and go to Properties->Advanced->Environmental Variables...

What's above are user variables, and below are system variables. The elements are combined when creating the environment for an application. System variables are shared for all users, but user variables are only for your account/profile.

If you deleted the system ones by accident, bring up the Registry Editor, then go to HKLM\ControlSet002\Control\Session Manager\Environment (assuming your current control set is not ControlSet002). Then find the Path value and copy the data into the Path value of HKLM\CurrentControlSet\Control\Session Manager\Environment. You might need to reboot the computer. (Hopefully, these backups weren't from too long ago, and they contain the info you need.)

user541686
  • 205,094
  • 128
  • 528
  • 886
  • 4
    I deleted users, so is it good or bad, is it possible to resotre users? – rookie Dec 18 '10 at 10:47
  • 3
    @rookie: Ah... well, deleting users' variables isn't *quite* as bad usually, but it really depends. You *could* try a System Restore, and it would probably work, but I personally don't like it because of various other issues that might come up. You could try going to `HKU\.DEFAULT\Environment`, and copying over everything from there to `HKCU\Environment`. If you're lucky, that's all you'd need to restore; if you're not so lucky, you might have had user-specific entries that just can't be restored, in which case you'd have to use System Restore. Hope this helps. – user541686 Dec 19 '10 at 04:07
  • why dont system environment variables have percentage signs while user variables do? – Millemila Jan 21 '14 at 18:55
101

Environment variables are 'evaluated' (ie. they are attributed) in the following order:

  1. System variables
  2. Variables defined in autoexec.bat
  3. User variables

Every process has an environment block that contains a set of environment variables and their values. There are two types of environment variables: user environment variables (set for each user) and system environment variables (set for everyone). A child process inherits the environment variables of its parent process by default.

Programs started by the command processor inherit the command processor's environment variables.

Environment variables specify search paths for files, directories for temporary files, application-specific options, and other similar information. The system maintains an environment block for each user and one for the computer. The system environment block represents environment variables for all users of the particular computer. A user's environment block represents the environment variables the system maintains for that particular user, including the set of system environment variables.

Akshaya Aradhya
  • 1,262
  • 1
  • 12
  • 15
  • 7
    Is this implying that System variables override the User variables, if both define one with the same name? – Casey Kuball Sep 27 '16 at 17:49
  • 10
    Usually [not](http://superuser.com/questions/867728/user-vs-system-environment-variables-do-system-variables-override-user-variabl), except [when it comes to PATH](https://support.microsoft.com/en-us/kb/100843). – Treefish Zhang Nov 17 '16 at 01:31
57

System environment variables are globally accessed by all users.
User environment variables are specific only to the currently logged-in user.

Ahmed Nabil
  • 17,392
  • 11
  • 61
  • 88
Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • I deleted it accidentally, what can be the results? How can I return it? – rookie Dec 18 '10 at 10:31
  • @rookie, the result is that programs relying on this environment variable might stop working. As far as returning it is concerned I don't know if it is possible. You might need to perform a system restore. – Darin Dimitrov Dec 18 '10 at 10:33
2

Just recreate the Path variable in users. Go to user variables, highlight path, then new, the type in value. Look on another computer with same version windows. Usually it is in windows 10: Path %USERPROFILE%\AppData\Local\Microsoft\WindowsApps;

Alesper3
  • 21
  • 1
1

An environment variable (can access anywhere/ dynamic object) is a type of variable. They are two types of system environment variables and user environment variables.

System variables have a predefined type and structure. That are used for system functions. Values which are produced by the system are stored in the system variable. They generally indicated by using capital letters

Example: HOME,PATH,USER

User environment variables are the variables that determined by the user, and are represented by using small letters.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Anusree
  • 19
  • 1