Windows Environmental Variable Precedence

Info & Tags

Article #:
36
Created:
09/13/07
Modified:
09/13/07

SUMMARY

There are several methods for setting Perforce environment variables and some settings can override others. This article answers the basic question: Which Perforce environment variables take precedence on Windows?

This article applies to Windows NT 4.0, Windows 2000, Windows XP and Windows 2003. Both Windows 32 bit and Windows 64 bit editions are included.


DETAILS

When a Perforce client (for example, P4, P4V or P4Win) or a Perforce plug-in (for example, P4SCC or P4 For Office) along with the Perforce Server Windows service (p4s.exe) start up, they read their configuration parameters from the Perforce Windows environment.   The order of precedence in the Perforce environment is traversed until a setting is found.   The order of precedence is as follows.

  1. Perforce command line flags
  2. Perforce P4CONFIG file, if P4CONFIG is set
  3. Windows environment variables, user and system*
  4. Perforce user environment registry (p4 set)
  5. Perforce system environment registry (p4 set -s)

As of Release 99.1/10994, when a Perforce Windows service starts up, it reads its configuration from an additional location. All Perforce Services use this additional location, including p4s.exe, p4ps.exe, p4webs.exe and p4ftps.exe. The order of precedence for a Perforce Windows service is as follows.

  1. Perforce Windows service parameters (p4 set -S servicename)
  2. Windows system environment variables*
  3. The Perforce system environment registry

Registry Reflection under Windows 64bit

When a 32 bit application runs under the Windows 64 bit OS, registry access is reflected. Any read or write to the registry under this area is reflected to the second registry area indicated below. (This is how Microsoft characterizes the action. In reality, it is more a registry redirection; one or the other area is accessed, never both.)

   HKEY_LOCAL_MACHINE/Software -->> HKEY_LOCAL_MACHINE/Software/Wow6432Node

Due to this registry redirection, the 2005.2 Perforce Windows 64 bit server (NTX64) was not compatible with the other 2005.2 Perforce Windows 32 bit (NTX86) clients and server. Perforce has chosen to put a patch in place which makes permanent the results of the Microsoft registry reflection. The Perforce Windows 64 bit server, NTX64, now uses the reflected registry area as if it were a 32 bit application. We chose this solution since all of our Perforce clients will remain as 32 bit applications for the time being.

All 2006.n Perforce Server versions and 2005.2 Perforce Server versions after "NTX86/2005.2/94595", will follow this behavior. No special action need be taken by the user since the P4 Command Line Client along with all other Perforce clients will automatically write environment settings into the reflected registry area as needed.