Can I set an environment variable for an application using a shortcut in Windows?

Let the shortcut execute a batch file (.cmd), that

  • Sets the environment variable
  • execute the app
  • You use "START" to execute the app, this will start the app in another process, but it will copy the environment. You do not wait for the app to finish.
  • Now you can exit the batch file.

Should look like this:

@echo off
set path=%path%;C:\My Folder
start "Window Title" "Path to my exe"

As explained here: http://www.labs64.com/blog/2012/06/set-environment-variables-in-windows-shortcut/ you can do it without a bat file too.

Set Target to e.g.:

C:\Windows\System32\cmd.exe /c "SET path=%path%&& START /D ^"C:\Program Files (x86)\Notepad++^" notepad++.exe"

To avoid see the command prompt for a split second before it close again, you should set

Run: Minimized 

on the Shortcut tab

(Tested on Windows 7, Windows 10)