How to force updates from linked directories to SkyDrive, with Microsoft SkyDrive for Windows

When you use symlinks to add directories outside your SkyDrive folder on Windows, SkyDrive will not always detect changes in these directories. This is especially noticeable if the linked folders reside on a network location.

Just for good measure we will just show how to create the symlinks to network drives. And remember SkyDrive must not be running when creating the symlinks otherwise SkyDrive will upload them as a file, and then crash. Which can only be fixed with a reinstall.

This has also been an issue with the DropBox client, and here is a Good article on how this issue is handled with the DropBox client. However with networked folders, you are not able to symlink from the remote location into the SkyDrive folder. In order to link a remote location to your SkyDrive, do the following:

taskkill.exe /IM skydrive.exe
mklink /D "Link name" "\\remote.server\Share\Folder"

Once the link has been made, you can restart the SkyDrive application.

Forced Syncronization

The forced syncronization is a simple procedure, that will restart the SkyDrive application. It will kill with taskkill, and start it again with the \background paramter. It is possible to force the sync simply by running SkyDrive.exe \background, however this will also bring up an explorer view of the SkyDrive folder.

@echo off

set tasklist=%windir%\System32\tasklist.exe
set taskkill=%windir%\System32\taskkill.exe
set skydrive=%AppData%\..\Local\Microsoft\SkyDrive\SkyDrive.exe
set wasStopped=0
set skydriveexe=skydrive.exe

set procFound=0
set notFound_result=ERROR:
      set procName=%skydriveexe%
for /f "usebackq" %%A in (`%taskkill% /IM %procName%`) do (
    if NOT %%A==%notFound_result% (set procFound=1)
)
if %procFound%==0 (
  echo The process was not running.
  goto :STARTSKYDRIVE
)
set wasStopped=1
set ignore_result=INFO:
:CHECKDEAD
"%windir%\system32\timeout.exe" 3 /NOBREAK
for /f "usebackq" %%A in (`%tasklist% /nh /fi "imagename eq %procName%"`) do (
    if not %%A==%ignore_result% (goto :CHECKDEAD)
)

:STARTSKYDRIVE
start "skydrive" "%skydrive%" /background

This code is based on sample code from http://stackoverflow.com/questions/7861683/from-a-batch-file-how-can-i-wait-for-a-process-to-exit-after-calling-taskkill.

Unfortunately when running this from the task scheduler, it will bring up a command promt, so in order to hide the command line, we use the following vbs code, and call that from the task scheduler instead:

 Set WshShell = WScript.CreateObject("WScript.Shell")
 currentDirectory = Replace(WScript.ScriptFullName,WScript.ScriptName,"")
 cmd = "cmd.exe /c """& currentDirectory &"SkyDriveForceSync.bat"""
 Return = WshShell.Run(cmd, 0, True)
 set WshShell = Nothing

This code is based on the sample from http://www.pcreview.co.uk/forums/hide-console-window-run-task-scheduler-t1468863.html

Task Scheduling

In order to have SkyDrive force a sync regularly, setup task scheduler to start the vbs script once a day, and have it repeat every hour after that for one day.


blog comments powered by Disqus