4

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?

2
  • What wrong with task kill?
    – Roke
    Oct 28, 2015 at 1:35
  • I am looking for a more graceful way to close it
    – Zaid Amir
    Oct 28, 2015 at 4:11

2 Answers 2

6

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".

0

Find where OneDrive.exe is, as the above didn't work for me.

(Windows 10 instructions)

i. Select Start (Windows icon) or the Search icon
ii. Type "OneDrive"
iii. Right-click OneDrive and select Open file location
-- This brings you to C:\ProgramData\Microsoft\Windows\Start Menu\Programs
iv. Right-click on the OneDrive.exe file and select Open file location
-- This brings you to C:\Program Files\Microsoft OneDrive
-- This is where the OneDrive.exe file is

Create a bat file with this
cd "C:\Program Files\Microsoft OneDrive" && OneDrive.exe /shutdown && exit

Edit the part "C:\Program Files\Microsoft OneDrive" to where the OneDrive.exe file is for you, if it's not in this location.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .