Tuesday, May 20, 2014

Sync network folders to OneDrive automatically

A few weeks ago I have written a post about synchronizing your OneDrive local folder to a network folder, in this post, however, we will talk about synchronizing server folders to the OneDrive folder automatically using a Robocopy script.

First off let's create sub-folders inside your OneDrive sync folder that will represent your network shares. For example if we have a server named Server and shared folders on it named Folder1 and Folder2 - we shall create them as subfolders inside our OneDrive sync folder, as:
(assuming the system partition is C:)

C:\Users\username\OneDrive\Folder1 (and other shared folders)
or
C:\Users\username\OneDrive for Business\Folder1 (and other shared folders)

Then, after all of our subfolders are created, we create a batch script containing:

@echo off

 robocopy "Source network folder" "Destination OneDrive Sub-folder" /MIR /COPY:DT /MON:1

We will have to create a Robocopy command like this for each one of the network folders that needs to be synced with OneDrive.

If the server requires credentials, you will have to add a line before the Robocopy command:
net use \\servername /USER:username password

After the Robocopy command you might want the script to log out, using the following command:
net use \\servername /d

This is a syncing script, that's why we're using the /MIR switch, this means that if we delete the file in the source folder, the file will soon be deleted in the destination folder. If you wish to copy files and not sync them, you can use /E /COPY (or /COPY:DT) instead of /MIR.

I also should mention that /COPY:DT switch in the above script is optional, it instructs Robocopy to preserve the files' Date and Time stamps but not attributes. I just prefer using it in this situation for better stability.

Now we can save the script as a BAT or a CMD file and run it (preferably in elevated mode) to see how it works. The script will never close unless the command prompt is closed manually, so this may create an annoyance to the user. That's why it may be a good idea to automate it's execution and keep it hidden from the user.

To do that we go into Task Scheduler and create a task to run this script. I recommend the trigger being the user's logon. Because if the trigger is a certain time of day - there may be duplicates of the same process, because the process never stops anyway.

Make sure you set the SYSTEM account as the account running the task, and mark it Hidden. This will allow the script to run invisibly in the background. This starts the cmd.exe and robocopy.exe processes and they only take a few hundred kilobytes in memory.





Saturday, May 10, 2014

Windows 8 Single Language image for download



Here you can find a Windows 8 Single Language installation image. This image is in Portuguese (Português) and Spanish (Espanol).

DOWNLOAD Win8_EM_x64.iso

It is possible to change the language later using my post about changing the language of Windows 8 Single Language.

You can use the product key of another version of Windows 8 Single Language to activate this image (for example if you'd like to re-install Windows on your laptop).