Stop and start OneDrive in batch file or command line
- Select Start (Windows icon) or the Search icon
- Type “OneDrive”
- Right-click OneDrive and select Open file location
— This brings you to C:\ProgramData\Microsoft\Windows\Start Menu\Programs - 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 batch file with this
cd "C:\Program Files\Microsoft OneDrive" && OneDrive.exe /shutdown && timeout /t 15 && OneDrive.exe && 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.
Reset OneDrive
Reset will not remove all settings but will completely resync
C:\Program Files\Microsoft OneDrive\onedrive.exe /reset
Edit the part “C:\Program Files\Microsoft OneDrive” to where the OneDrive.exe file is for you, if it’s not in this location.
==========================
Completely uninstall, remove files and reinstall OneDrive
First a note on a difficult problem
onedrive wasn’t syncing the office documents.
I repeatedly tried resetting OneDrive. Kept getting a message that it couldn’t sync because it was already syncing.
after 2 hours I found a web site describing the solution.
Somehow a link to the onedrive a-SS was within Sonia’s personal onedrive folder.
Once I removed that (it had a chain icon attached) I got her back going.
https://learn.microsoft.com/en-us/sharepoint/troubleshoot/sync/cannot-sync-shortcut-folder
=============================
Now to remove/reinstall
Slightly edited for Windows 11
CMD prompt as administrator
Run the following commands from an elevated privilege.
netsh int ip reset netsh winsock reset ipconfig /release ipconfig /renew ipconfig /flushdns shutdown /r
<If you are remotely connected be sure there is a blank return line included in your copy/paste, otherwise the shutdown /r command can't be completed>
After restart again with cmd as administrator:
taskkill /f /im OneDrive.exe
find the location of OneDriveSetup.exe
(it changes stupidly with each update, I used FileLocator Lite to find it but also look at the top of this post for another way to find the location)
OneDriveSetup.exe /uninstall
Delete OneDrive folder cache
OneDrive cache location: C:\Users\%username%\AppData\Local\OneDrive
Delete the temporary files in the following folders:
- C:\Users\%username%\AppData\Local\Temp
- C:\Users\%username%\AppData\LocalLow\Temp
- C:\Windows\Temp
Note: It’s OK if some files you can’t delete in the Temp folder.
If you want to remove the login information do the following:
 Go to RegEdit on this path:           HKEY_CURRENT_USER\Software\Microsoft\OneDrive
  You can remove all folders that include One Drive version
  Account folders also can be removed
Reboot your computer
Download and install OneDrive https://www.microsoft.com/en-us/microsoft-365/onedrive/download
Â
Â