OneDriveCommercial system variable switches randomly between orgs

KingKrayola

Ars Scholae Palatinae
1,077
Subscriptor
Hi folks,
Possibly somewhat old-skool question:

I use a .bat file to launch our CAD software. The script sets up a working environment by syncing some template libraries, cleaning up some temporary files, setting a working directory and then loading the package. This lets me set several environments (some clients have their own configs) and then put a shortcut to the .bat file on the user's Start Menu.

(I could do it in PowerShell but this has been historically done by admins in the old Windows command prompt and I'd have to rewrite)

One problem - if the working directory is in a user's OneDrive for backup purposes, and we're working under two orgs with their own MS 365 tenants (my firm and a spin-out with different ownership), then the %OneDriveCommercial% system variable that I'm using to keep the working directory in Company1 randomly switches from C:\Users\<user>\Company1\ to C:\Users\<user>\Company2\.

Anyone else had this problem? I think I may end up hard coding it, but would be nice to do it somewhat programmatically.
 
Do the users have multiple accounts setup in their OneDrive clients? I haven’t seen this specific issue but I could see the path var switching if users were signed into both tenants.

Also, are the machines on different domains for the different orgs, or all one domain? If different domains, you could key off of that to decide which org name path to use for OneDrive.
 

KingKrayola

Ars Scholae Palatinae
1,077
Subscriptor
Yeah multiple commercial OneDrive accounts is the issue. MS Support suggested we could just manually set the system variable but that is prone to being overwritten between restarts if noone knows when it gets set by the OneDrive client.

Might try to reopen the ticket to see what exactly is happening; for now I've just hardcoded the Company1 profile as we're only a small shop. Real solution is to invest in a PLM/PDM system and not use OneDrive for storage/backup.