Environment Variables (without admin privileges) for Command Line


If you don’t have Admin rights to a machine and you need to add environment variables it can be a real pain in the neck to have to get Ops every time to do it. You can update the system PATH in a batch file, but it can be a hassle to have to source this file every time you open a command terminal. The following process allows you to automatically source any environment variables every time you open a terminal.

  1. Start the command prompt and ‘pin’ it to the taskbar.
  2. Right-click on it, edit properties, and append -cmd /K env.bat to the Target property.


%windir%\system32\cmd.exe -cmd /K env.bat

3. Create a batch file called env.bat and place it in your home folder. This file should include any environment variables you need set. For example:

@echo off

if "%ANT_HOME%"=="" (
 echo Setting environment...
) else (
 echo Environment already defined.
 exit /b

set ANT_HOME=C:\apps\apache-ant-1.9.6
set APACHE_HOME=C:\opt\apache2
set GIT_HOME=C:\Users\philip.murphy\AppData\Local\Programs\Git
set JAVA_HOME=C:\apps\jdk8u66
set JBOSS_HOME=C:\opt\jboss
set M2_HOME=C:\apps\apache-maven-3.0.3
set ONE_DRIVE="C:\Users\philip.murphy\OneDrive - Globoforce"
set ADB_PATH=C:\apps\android-sdk-windows\platform-tools
set CATALINA_HOME=C:\opt\tomcat
set ORACLE_HOME=C:\oraclexe\app\oracle\product\11.2.0\server
set TNS_ADMIN=C:\oraclexe\app\oracle\product\11.2.0\server\network\ADMIN
set FFMPEG_HOME=C:\apps\ffmpeg
set SEVEN_ZIP="C:\Program Files\7-Zip"
set CHROME_HOME="C:\Program Files (x86)\Google\Chrome\Application"
set IMAGEMAGICK=C:\apps\imagemagick

set path=%ONE_DRIVE%\bin;%ANT_HOME%\bin;%APACHE_HOME%\bin;%GIT_HOME%\bin;%GIT_HOME%\usr\bin;%GIT_HOME%\mingw64\bin;%JAVA_HOME%\bin;%M2_HOME%\bin;C:\Ruby187\bin;C:\Python27;%ADB_PATH%;%FFMPEG_HOME%\bin;%SEVEN_ZIP%;%CHROME_HOME%;c:\apps;%IMAGEMAGICK%;%path%

Set and forget – you’re done.