As you are thinking of using enviroment variables to deal with the issue you have you might find the following useful (See below.)
Perhaps you could adapt the information to SET environmental variables to suit your own situation. If you got it to work you would, of course, need to carefully test it all out for yourself.
If you did get it to work okay, or otherwise, it would be good if you could report back to this thread on how things went, mentioning what environment variables you set and what the result of your testing was.
====================================================================
I use a ram disk for %TEMP% and %TMP% files but I use it selectively on a per program basis using variations of the following batch file script (for example):
set TEMP=W:\TEMP
set TMP=W:\TMP
start "" "C:\Program Files (x86)\Microsoft Office\OFFICE11\OUTLOOK.EXE"
exit
The above would launch Microsoft Office Outlook and have it write its temporary files into the ramdisk (whereas normally they get written into the default %TEMP%).
set TEMP=W:\TEMP
set TMP=W:\TMP
start "" "E:\PORTABLES\INTERNET\PeerBlock\peerblock.exe"
ping -n 31 127.0.0.1 >NUL
start "" "E:\PORTABLES\INTERNET\uTorrent\uTorrent.exe"
exit
The above would launch PeerBlock, then after a 30 second 'pause' to let PeerBlock update its block-lists, it would launch uTorrent and have both of them write any temp files they would normally write into the ramdisk.
(I use uTorrent here as an example because I know that uTorrent does write files to %TEMP%. In fact I don't use uTorrent any more - Tixati is much better - but I use Tixati Portable and as far as I'm aware it doesn't write files into %TEMP%.)
set TEMP=W:\TEMP
set TMP=W:\TMP
start "" "C:\Program Files (x86)\INTERNET\Mozilla Firefox\firefox.exe"
exit
The above would launch Firefox and have it write any temp files into the ramdisk.
From this you should see that you can create batch files on a per program basis and just have a shortcut to the *.bat in your Start Menu that you use for launching whatever program you want to write temporary files into the ramdisk.
You should also be aware that using these batch files will
not globally reset your %TEMP% and %TMP% files for all programs after any one of the batch files has been run. The change in path only gets applied to the program(s) that are launched from within the batch file. Also, though, you should know that for any program you've launched using a batch file like those above then if one of those programs calls (launches) another program (as a sub-process, so to speak) then that sub-process will also write its temp files into the ramdisk - really this is the only potential pitfall you need to be aware of if using batch files like these.
The real advantage of these batch files is that other processes that write temporary files and expect to find them after a reboot (e.g. Win Update and installers) can carry on writing to %TEMP% and %TMP% as normal so you don't risk messing up your system at some critical point in the future.
Hope this is of help.