Skip to content

Commit d49b21f

Browse files
Fix onedrive remove for msapps
1 parent 39ee4d5 commit d49b21f

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

config/tweaks.json

+14-5
Original file line numberDiff line numberDiff line change
@@ -2682,17 +2682,26 @@
26822682
"
26832683
$OneDrivePath = $($env:OneDrive)
26842684
Write-Host \"Removing OneDrive\"
2685+
2686+
# Check both traditional and Microsoft Store installations
26852687
$regPath = \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OneDriveSetup.exe\"
2688+
$msStorePath = \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Appx\\AppxAllUserStore\\Applications\\*OneDrive*\"
2689+
26862690
if (Test-Path $regPath) {
26872691
$OneDriveUninstallString = Get-ItemPropertyValue \"$regPath\" -Name \"UninstallString\"
26882692
$OneDriveExe, $OneDriveArgs = $OneDriveUninstallString.Split(\" \")
26892693
Start-Process -FilePath $OneDriveExe -ArgumentList \"$OneDriveArgs /silent\" -NoNewWindow -Wait
2694+
} elseif (Test-Path $msStorePath) {
2695+
Write-Host \"OneDrive appears to be installed via Microsoft Store\" -ForegroundColor Yellow
2696+
# Attempt to uninstall via winget
2697+
Start-Process -FilePath winget -ArgumentList \"uninstall -e --purge --accept-source-agreements Microsoft.OneDrive\" -NoNewWindow -Wait
26902698
} else {
2691-
Write-Host \"Onedrive dosn't seem to be installed anymore\" -ForegroundColor Red
2692-
return
2699+
Write-Host \"OneDrive doesn't seem to be installed\" -ForegroundColor Red
2700+
Write-Host \"Running cleanup if OneDrive path exists\" -ForegroundColor Red
26932701
}
2694-
# Check if OneDrive got Uninstalled
2695-
if (-not (Test-Path $regPath)) {
2702+
2703+
# Check if OneDrive got Uninstalled (both paths)
2704+
if (Test-Path $OneDrivePath) {
26962705
Write-Host \"Copy downloaded Files from the OneDrive Folder to Root UserProfile\"
26972706
Start-Process -FilePath powershell -ArgumentList \"robocopy '$($OneDrivePath)' '$($env:USERPROFILE.TrimEnd())\\' /mov /e /xj\" -NoNewWindow -Wait
26982707

@@ -2758,7 +2767,7 @@
27582767
Write-Host \"If there are Files missing afterwards, please Login to Onedrive.com and Download them manually\" -ForegroundColor Yellow
27592768
Start-Sleep 5
27602769
} else {
2761-
Write-Host \"Something went Wrong during the Unistallation of OneDrive\" -ForegroundColor Red
2770+
Write-Host \"Nothing to Cleanup with OneDrive\" -ForegroundColor Red
27622771
}
27632772
"
27642773
],

0 commit comments

Comments
 (0)