@echo off :: Check if OneDrive is installed echo Checking if Microsoft OneDrive is installed... :: Check for OneDrive installation by looking for its executable if exist "%LOCALAPPDATA%\Microsoft\OneDrive\OneDrive.exe" ( echo OneDrive is installed. Proceeding with uninstallation... echo Uninstalling OneDrive... >> "%LOGFILE%" if exist "%SystemRoot%\System32\OneDriveSetup.exe" ( "%SystemRoot%\System32\OneDriveSetup.exe" /uninstall if !errorlevel! neq 0 ( echo ERROR: Failed to uninstall OneDrive ) else ( echo Successfully uninstalled OneDrive ) ) else ( echo WARNING: OneDriveSetup.exe not found ) ) else ( echo WARNING: Microsoft OneDrive is not installed. Skipping uninstallation. ) endlocal