Laughable Junnyzup
Laughable Junnyzup

Reputation: 99

Syncing OneDrive (SkyDrive) with Batch File (via cmd)

Basically, I'm wondering if it's possible to sync OneDrive with a batch file. See, I can sync it whenever I go to File Explorer, right click on "OneDrive" on the left, and click "Sync," but I'm wondering if there's command windows has incorporated to have this exact same effect when used with a batch file. I have no idea what it is and have searched to no avail, so I hope that you can help me! Whatever it takes, I'm sure it would be an extremely simple script; the problem is finding out what command to use. Here's an example as a picture:

enter image description here

Upvotes: 4

Views: 29177

Answers (3)

NutCracker
NutCracker

Reputation: 73

To shutdown OneDrive from the command line or in a batch file:

    %LOCALAPPDATA%\Microsoft\OneDrive\OneDrive.exe /shutdown

To start OneDrive from the command line:

    %LOCALAPPDATA%\Microsoft\OneDrive\OneDrive.exe /background

If the /background switch is omitted then Explorer is opened to the OneDrive folder in your user profile but OneDrive does not start.

If restarting OneDrive from a batch file then add the START command or the batch file won't end:

    start %LOCALAPPDATA%\Microsoft\OneDrive\OneDrive.exe /background

Upvotes: 7

LFG
LFG

Reputation: 11

This is one simple solution:

Change OneDrive Settings to NOT Start automatically when Windows starts Create a BAT file and launch OneDrive with Windows Task Scheduler during non-peak hours. Create a .BAT file to Taskkill OneDrive.exe at the end of the Peak-hours:

Windows 10:

Command line to launch OneDrive (and automatically start syncing the folders/files in settings)

C:\Users\user\AppData\Local\Microsoft\OneDrive\OneDrive.exe

Command line to Taskkill Onedrive.exe

Taskkill /IM OneDrive.exe /F

Upvotes: 1

npocmaka
npocmaka

Reputation: 57282

Get my oneDriveSync.bat and test it.Be minded that it will work only if machine language is English.THe Sync is always the third verb but if it is inactive the third will be Pause so I cant create language independent version at the moment.

Upvotes: 2

Related Questions