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.

Setting a Common Path to Sharepoint Site Folders on Multiple Devices

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:

  1. Sync the Sharepoint folder to the local hard drive
  2. 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.

Step-by-Step Setup

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.)

Step 1.

Ensure OneDrive is installed

Step 2.

Open the document folder in Sharepoint online (the URL will be something like: https://mydomaincom.sharepoint.com/sites/FogBugz/Shared Documents/Forms/AllItems.aspx)

Step 3.

Click on the Sync button to enable syncing of the folder to the local computer

Step 4.

Find the location of the synced folder on the local drive:

  • For example, D:\mydomain.com\FogBugz - Documents

Step 5.

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.

Step 6.

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)

Usage

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"

External references

setx
Reference article for the setx command, which creates or modifies environment variables in the user or system environment, without requiring programming or scripting.

Referenced articles

A Mind-Reading Script
What if you could highlight any text, press a hotkey, and have Windows do what you want almost every time? You’d have my top productivity hack.

Image by Shameer Pk from Pixabay

All original code samples by Mike Wolfe are licensed under CC BY 4.0