5

I know that I can globally change the Temp folder location in Windows 10, so it will affect all programs. I know that some programs have the option in itself to change the temp folder location, regardless of the Windows default temp location. I use HP software and hardware to scan documents, but when scanning large documents, it's taking a lot of space on my primary SSD putting unnecessary wear on it. That's why I would like to change temp folder for that specific application to my second HDD. In the HP software, I couldn't find any option to change the temp folder location for that particular program, and I don't want to change the temp folder for every other application on my system. Is there an option to change the temp folder for a specific program when it doesn't have that option built in? (in my case it's the HP Scan program).

1

1 Answer 1

2

I can think of one method, but it will only work if the specific program(s) retrieves the Temp location from the environment variables. It should work even if the program calls the Windows API GetTempPath function to retrieve the location, since this function first consults the environment.

These environment variables are named TMP and TEMP, and they point directly to the temp folder. Both should point to the same folder, as they are just aliases.

You may start the program via a .bat file that may look like:

SET "TEMP=C:\path\to\folder"
SET "TMP=C:\path\to\folder"
"C:\path\to\program.exe" parameters

The parameters above may be replaced by %* to just use the parameters of the .bat file.

2
  • Do GUI applications inherit the environment variables configured at the command prompt in this way? Or are only console applications affected? What if the command prompt closes after the GUI is executed? Are the changes lost then? Jun 14, 2019 at 17:50
  • @TwistyImpersonator: All processes inherit the environment of their parent, so this should work if the program acts logically. I actually noticed that even the Windows API first consults the environment.
    – harrymc
    Jun 14, 2019 at 18:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .