Different symlink for different user on Windows
Solution 1:
You can use the subst
command to map a drive letter to your user directory. Drive letters created by subst
are per-user, so you can create the same mapping as each user and then create a symlink to that drive letter. Or just point the program to the mapped drive via its settings.
An example:
subst v: %userprofile%
mklink /d c:\ProgramData\AppFolder v:\Documents\AppForder
A downside of this solution is that mapped drive letters are not persistent, so you have to recreate them every time a user logs in (for example, by putting a shortcut to the subst
command into %appdata%\Microsoft\Windows\Start Menu\Programs\Startup
. Or you can make a batch file which will run subst
and then your program.
An alternative solution is to run your program in a sandbox (e.g. Sandboxie).This won't work if the program tries to do something low-level (e.g. installing drivers or services). Also you'll have to restore files created by the program from sandbox after each run in you need to use them elsewhere.