To change the location where a specific program stores its files without altering system-wide environment variables, you can indeed utilize a batch script or PowerShell script to set environment variables temporarily for that program. Here’s how you can achieve this:
Method 1: Using a Batch Script
You were on the right track with your initial idea. You can create a batch script to set the environment variable just for the duration of running your program:
Code:
@echo off setlocal set "MyDocuments=D:\path\to\different\location\" start myprogram123.exe endlocal
In this script:
setlocal
and endlocal
ensure that the environment variable changes are local to the script.
set...