I am running OneDrive sync by creating scheduled tasks in Windows Task Scheduler. I have two tasks, one to start OneDrive's desktop app and the other kills it.

I am currently using taskkill to get the job done and I am not proud of it. I am looking to see if there is a graceful way to exit/close/stop OneDrive from syncing.

Does anyone know of such a thing?


OneDrive.exe /shutdown is what you seek. Or more formally:

Windows Vista, 7, and 10:

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

Windows 8.1:

cd /d %LOCALAPPDATA%\Microsoft\Windows\OneDrive
OneDrive.exe /shutdown

NOTE: To restart OneDrive from a batch file, you will need to use the "start" command. Running the .exe directly will leave the batch file open "forever".