SQLite Forum

Setting temp_store_directory on Windows in future proof way
Login
That is correct.  In theory one could programmatically push a new TMP variable into the current process environment block using the appropriate Windows API.

<https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setenvironmentvariable>

This would change the current process' copy of the environment and if one were to specify a value for the variable TMP then that would become the new temp file location for the entire process (and any sub-process created after the change were made that inherited the current process environment) provided that the call to the OS to get the temp file location occurred after the change was made.