Helix Core is now P4. Product user interfaces will be updated soon. Learn more >>

P4 for Visual Studio Documentation | 2025.1

# Set P4 Server environment variables using P4CONFIG

`P4CONFIG` is an environment variable that you can use to point to a file that stores other P4 Server environment variables. The current working directory and its parents are searched for the file. If the file exists, then the variable settings within the file are used.

`P4CONFIG` makes it easy to switch P4 Server settings when switching between different solutions or projects. If you place a configuration file in each of your client workspaces and set `P4CONFIG` to point to that file, your P4 Server settings change to the settings in the configuration files automatically as you move from directories in one workspace to another.

To use `P4CONFIG` to switch settings between client workspaces on P4 for Visual Studio, you must create separate Visual Studio shortcuts for each workspace, setting the `Start in` property as the workspace directory (which is also the directory where the configuration file resides). If you launch Visual Studio using a shortcut defined this way, P4 for Visual Studio will read the P4 Server settings from the configuration file in that workspace’s directory. This is required because Visual Studio otherwise uses its own directory as the current working directory.

To use `P4CONFIG` with P4 for Visual Studio:

1. Create a configuration file that contains the P4 Server environment variable settings you want, and put it in the workspace directory for the relevant Visual Studio solution.
2. Using `p4`, the P4 Server Command Line Client, unset the `P4CLIENT`, `P4PORT`, and `P4USER` environment variables and set `P4CONFIG` to the configuration file name.
3. Using P4 for Visual Studio, go to Tools > Options > Source Control > P4 - Connections and select Connect to the server using my P4 environment settings.

4. Create a Windows desktop shortcut for Visual Studio that is dedicated to the workspace with which you want to use the configuration file.

   1. Right-click on the desktop and select New > Shortcut.
   2. Enter the location of the Visual Studio executable and click Next.
   3. Enter a shortcut name and click Finish.
   4. In the shortcut properties, under Start in, enter the workspace directory where the configuration file is located, and click OK.

   Repeat for each workspace for which you want a different configuration file.

5. Whenever you want to work in that workspace using the configuration file settings, use the shortcut to launch Visual Studio.

To learn more about `P4CONFIG` and P4 Server environment variables, see the P4 CLI Reference and Set P4 for Visual Studio preferences.

Your search for returned results