Box folder sync broken

Answered
New post

Comments

5 comments

  • Rona

    Hi Paul, 

    Welcome to Box Community and happy to assist!

    As much as we wanted to address this issue with you. Your Enterprise account has a designated team that works closely with Box Premier Services.

    At this rate, please get in touch with your internal helpdesk team for immediate assistance.

    Thanks for posting!

    0
    Comment actions Permalink
  • Paul Wood

    Thanks for coming back to me so quickly, Rona. I was not aware of that support path, but I'll follow-up with them asap. Much appreciated!

    0
    Comment actions Permalink
  • Ross Ensbey (RMI)

    Hello Paul Wood - stumbled upon your post while searching online. Exact same problem here (including attempted remedies). 

    Did you end up finding a solution?

    0
    Comment actions Permalink
  • Paul Wood

    Hi Ross (sorry I don't now if the @ thing works here). I unfortunately never reached the resolution I was looking for. Even the symlink/junction solution wasn't ideal (mostly because the syncing would slow down any development work with the github folder trying to keep up-to-date every time I ran a build). In the end I would either manually switch to the Box folder if needed for editing shared files, or set-up a Windows Task Scheduler job to sync any local folders to the Box folder, purely as a simple backup for the more local files, e.g. using a batch file:

    @echo off
    set source="C:\Users\xxx\Documents"
    set dest="C:\Users\xxx\Box\My Box Drive\Documents"
    robocopy /mir %source% %dest% /s /e /z

    I don't think many folks are trying to do what we were trying here, otherwise there would be more noise about it. I don't understand why, because many other sync services do exactly this without any problems it seems.

    Good luck though - I hope a solution comes along, because I only found out a couple of months ago after my computer died that the backup was actually working! :)

    Cheers, Paul

    0
    Comment actions Permalink
  • Ross Ensbey (RMI)

    Thanks for your reply, Paul Wood! Shame there's no "fix" per say; only workarounds, it seems. Either way - appreciated. Some other people may find the sync workaround useful, too. 

    In my case, no performance issues, just bizarreness of library paths being overwritten (as in your original post). I ended up using a PowerShell script to correct my access each time I log on via Task Scheduler.

    Will leave this example code here in case someone else also stumbles upon this thread, needs this workaround, and finds it useful.

    Cheers,

    Ross

    # PowerShell script to set custom folder locations and delete old_Box folders

    # Define the custom folder locations using full paths
    # !! Make sure to update these file locations with your real location !!
    # !! For application compatibility reasons, better not to use environment variables here !!
    $folders = @{
      "Personal"    = "C:\Users\username\Box\Documents"
      "Downloads"   = "C:\Users\username\Box\Downloads"
      "My Pictures" = "C:\Users\username\Box\Pictures"
      "My Video"    = "C:\Users\username\Box\Videos"
      "My Music"    = "C:\Users\username\Box\Music"
    }

    # Log file path (feel free to update this to something else)
    $logFile = "C:\Scripts\SetCustomFoldersAndCleanOldBox.log"

    # Function to log messages
    function Log-Message {
        param (
            [string]$message
        )
        $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
        Add-Content -Path $logFile -Value "$timestamp - $message"
    }

    # Start logging
    Log-Message "Script started."

    # Set the custom folder locations in User Shell Folders
    foreach ($folder in $folders.GetEnumerator()) {
        try {
            $keyPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders"
            Set-ItemProperty -Path $keyPath -Name $folder.Key -Value $folder.Value
            Log-Message "Set $($folder.Key) to $($folder.Value) in User Shell Folders."
        } catch {
            Log-Message "Error setting $($folder.Key) in User Shell Folders: $_"
        }
    }

    # Set the custom folder locations in Shell Folders
    foreach ($folder in $folders.GetEnumerator()) {
        try {
            $keyPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
            Set-ItemProperty -Path $keyPath -Name $folder.Key -Value $folder.Value
            Log-Message "Set $($folder.Key) to $($folder.Value) in Shell Folders."
        } catch {
            Log-Message "Error setting $($folder.Key) in Shell Folders: $_"
        }
    }

    # Update GUID keys for special folders
    # !! Make sure to update these file locations with your real location !!
    # !! For application compatibility reasons, please DO use environment variables here, not full path !!
    $guidFolders = @{
        "{F42EE2D3-909F-4907-8871-4C22FC0BF756}" = "%USERPROFILE%\CustomDocuments"  # Documents
        "{374DE290-123F-4565-9164-39C4925E467B}" = "%USERPROFILE%\CustomDownloads"  # Downloads (legacy)
        "{7D83EE9B-2244-4E70-B1F5-5393042AF1E4}" = "%USERPROFILE%\CustomDownloads"  # Downloads (modern)
        "{0DDD015D-B06C-45D5-8C4C-F59713854639}" = "%USERPROFILE%\CustomPictures"   # Pictures
        "{A0C69A99-21C8-4671-8703-7934162FCF1D}" = "%USERPROFILE%\CustomMusic"      # Music
        "{18989B1D-99B5-455B-841C-AB7C74E4DDFC}" = "%USERPROFILE%\CustomVideos"     # Videos (common)
        "{35286A68-3C57-41A1-BBB1-0EAE73D76C95}" = "%USERPROFILE%\CustomVideos"     # Videos (additional)
    }

    foreach ($guidFolder in $guidFolders.GetEnumerator()) {
        try {
            $keyPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders"
            Set-ItemProperty -Path $keyPath -Name $guidFolder.Key -Value $guidFolder.Value
            Log-Message "Set $($guidFolder.Key) to $($guidFolder.Value) in User Shell Folders."
        } catch {
            Log-Message "Error setting $($guidFolder.Key) in User Shell Folders: $_"
        }
    }

    # Define the base directory where old_Box folders might be created
    $baseDirectory = "$env:USERPROFILE"

    # Delete any folders starting with "old_Box" in the base directory
    try {
        Get-ChildItem -Path $baseDirectory -Directory -Filter "old_Box*" | ForEach-Object {
            Remove-Item -Path $_.FullName -Recurse -Force
            Log-Message "Deleted folder: $($_.FullName)."
        }
    } catch {
        Log-Message "Error deleting old_Box folders: $_"
    }

    # Refresh the environment to apply changes
    try {
        # Use a more graceful method to refresh Explorer
        $shell = New-Object -ComObject Shell.Application
        $shell.Namespace(0).Self.InvokeVerb("Refresh")
        Log-Message "Refreshed Explorer."
    } catch {
        Log-Message "Error refreshing Explorer: $_"
    }

    # End logging
    Log-Message "Script completed."
    0
    Comment actions Permalink

Please sign in to leave a comment.