Couple of issues at play here,
- windows weirdness: getenv and SetEnvironmentVariable don't play together , things set by SetEnvironmentVariable can only be retrieved by GetEnvironmentVariable , getenv will always return the variables as they were at process initialization. [1]
- BKE_appdir_folder_id_ex checks the standard location of the scripts folder (ie 2.79/scripts) first before considering the environment override .
[1] http://techunravel.blogspot.ca/2011/08/win32-env-variable-pitfall-of.html