'How to redirect from one directory to another while protecting from file addition and deletion?

A program I am using has a directory for Python plugins in the installation path:

C:\Program Files\...\plugins

This is normally empty. The software is hard-wired to look for plugins here and nowhere else.

I want to develop plugins. However, I would prefer to keep the code elsewhere, for example:

D:\...\plugins

I also want to make sure that software updates do not result in additions or deletions of any kind to my working directory.

I deleted the directory in the install path and replaced it with a symlink to my directory:

mklink /d "C:\Program Files\...\plugins" "D:\...\plugins"

Now, if I delete the link C:\Program Files\...\plugins my working directory D:\...\plugins is safe, nothing happens to it. In other words, if I uninstall the software (which would presumably delete the link), my code is safe.

If, however, I add or delete a file in the link (for example, via command line from C:\Program Files\...\plugins my working directory is modified accordingly.

What I am after is a reference from C:\Program Files\...\plugins to D:\...\plugins that will make the software see my code. However, any installation or update of the software should not be able to delete or add files to my working directory. The software itself has no such functionality. In other words, all it does is read this directory to install the plugins. No writing at all within the application. If I could redirect it to my directory it would be perfect. There are no provisions to add a directory to the search path, otherwise this would be the perfect solution.

The only way I have been able to make mklink work is to make each plugin a symlink. In other words these links:

C:\Program Files\...\plugins\plugin_01
C:\Program Files\...\plugins\plugin_02
C:\Program Files\...\plugins\plugin_03
C:\Program Files\...\plugins\plugin_04

Are actually individual links to the corresponding development directories:

D:\...\plugins\plugin_01
D:\...\plugins\plugin_02
D:\...\plugins\plugin_03
D:\...\plugins\plugin_04

This means that if C:\Program Files\...\plugins is deleted or modified by an installation or update nothing whatsoever happens to my codebase. I tested this and it works. It carries a bit of a maintenance load in that you have to create a symlink for every project. Not a huge deal, but it would be nice to be able to achieve the same end result with an approach that automatically covers everything in the development path.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source