Setting a Common Path to Sharepoint Site Folders on Multiple Devices
This quick tip will help you create consistent development environments across multiple devices and users.
We have a couple of company Sharepoint sites with Documents folders where we store our shared files.
Our company is not big enough (or in-person enough) for a dedicated Windows server running Active Directory with on-premises network shares to make economic sense. However, it's too big to pass files back and forth over email or ad hoc file shares.
If we had a dedicated file server, we could set up drive mappings so that every employee had access to files the same way. This makes lots of things easier, including documentation, build/installer scripts, etc. The problem with Sharepoint is that the files are not directly accessible via the standard file system. There is an option to sync the folder to your local hard drive, but not everybody will (or can) set up their sync folder to the same place on their machine.
I found a workaround that makes this situation a little easier to deal with.
Environment Variables to the Rescue
We use a two-step approach:
- Sync the Sharepoint folder to the local hard drive
- Set a persistent environment variable that points to the sync location
For example, we have a Sharepoint site with a folder that we use to hold editable documents related to our FogBugz cases. Let's say that on case 123, we are doing some troubleshooting in an Excel file named Sandbox.xlsx. With this setup, we can add the following note to our FogBugz case:
For more information, refer to %FB%\123\Sandbox.xlsx
If you were to copy and paste
%FB%\123\Sandbox.xlsx into the File Explorer address bar or the Run command ([Win] + [R]), it would open that file. It doesn't matter if that folder is synced to the local D: drive on one computer, but the local C: drive on another computer.
Once the folder is synced and the environment variable is configured, it Just Works™ everywhere.
Here are the steps to configure this setup. (Obviously, you will need to change the Sharepoint site names and file paths to match your own environment.)
Ensure OneDrive is installed
Open the document folder in Sharepoint online (the URL will be something like: https://mydomaincom.sharepoint.com/sites/FogBugz/Shared Documents/Forms/AllItems.aspx)
Click on the Sync button to enable syncing of the folder to the local computer
Find the location of the synced folder on the local drive:
- For example,
D:\mydomain.com\FogBugz - Documents
Add a persistent FB environment variable via the cmd window using the
setx command (does not require an Admin command prompt):
setx FB "D:\mydomain.com\FogBugz - Documents"
- There is nothing special about the "FB" string. That's just the name of the environment variable I picked because it's short and easy to associate with FogBugz. Replace "FB" with whatever you prefer for your unique situation.
You may need to restart the computer to ensure that all applications (especially AutoHotkey scripts) have access to the new FB environment variable.
- It appears that a restart of the Operating System is the only reliable way to make the new environment variable available to AutoHotkey (AHK)
You can now get to this folder using the
%FB% shortcut in File Explorer:
Additional Sharepoint Folders
You can repeat these steps for as many folders as you need. For example, we also have an Applications site in our company Sharepoint account. We use a different environment variable,
%Apps%, to connect to that folder:
setx Apps "D:\mydomain.com\Applications - Documents"
Image by Shameer Pk from Pixabay