Last active
January 21, 2022 12:14
-
-
Save sjml/b5bc0ab6e8c464f77995204538622e2d to your computer and use it in GitHub Desktop.
Unsticking OneDrive on Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
rem Sometimes OneDrive gets stuck and won't be able to sync files. | |
rem It will just spin on "looking for changes" or some nonsense. | |
rem (This seems to especially happen when the internet is not reliable | |
rem or perhaps just in certain geographic regions? I haven't been able | |
rem to find out. I live in the Middle East, though, and OneDrive is | |
rem super unreliable and it makes me sad.) | |
rem This script resets its syncing status and restarts the app, | |
rem but it means it may have to take a while to get back to | |
rem properly working. So don't run this just for funsies, but if | |
rem your OneDrive hasn't been working for a while, this could help. | |
rem | |
rem (I am definitely not a masterful batch file programmer, so this is | |
rem almost certainly sub-optimal.) | |
set onedrive_exe= | |
for %%A in ("%localappdata%\Microsoft\OneDrive\onedrive.exe" "C:\Program Files\Microsoft OneDrive\onedrive.exe" "C:\Program Files (x86)\Microsoft OneDrive\onedrive.exe") do ( | |
if exist %%A ( | |
set onedrive_exe=%%A | |
goto searched | |
) | |
) | |
:searched | |
if not defined onedrive_exe ( | |
echo ERROR: Couldn't find OneDrive... either it's not installed | |
echo or set up kind of strangely. Sorry about that. | |
set /p=Press ENTER to exit... | |
exit 2 | |
) | |
%onedrive_exe% /reset | |
start "" %onedrive_exe% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment