Skip to content

Commit

Permalink
Fix onedrive remove for msapps
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisTitusTech committed Nov 25, 2024
1 parent 39ee4d5 commit d49b21f
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions config/tweaks.json
Original file line number Diff line number Diff line change
Expand Up @@ -2682,17 +2682,26 @@
"
$OneDrivePath = $($env:OneDrive)
Write-Host \"Removing OneDrive\"

# Check both traditional and Microsoft Store installations
$regPath = \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OneDriveSetup.exe\"
$msStorePath = \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Appx\\AppxAllUserStore\\Applications\\*OneDrive*\"

if (Test-Path $regPath) {
$OneDriveUninstallString = Get-ItemPropertyValue \"$regPath\" -Name \"UninstallString\"
$OneDriveExe, $OneDriveArgs = $OneDriveUninstallString.Split(\" \")
Start-Process -FilePath $OneDriveExe -ArgumentList \"$OneDriveArgs /silent\" -NoNewWindow -Wait
} elseif (Test-Path $msStorePath) {
Write-Host \"OneDrive appears to be installed via Microsoft Store\" -ForegroundColor Yellow
# Attempt to uninstall via winget
Start-Process -FilePath winget -ArgumentList \"uninstall -e --purge --accept-source-agreements Microsoft.OneDrive\" -NoNewWindow -Wait
} else {
Write-Host \"Onedrive dosn't seem to be installed anymore\" -ForegroundColor Red
return
Write-Host \"OneDrive doesn't seem to be installed\" -ForegroundColor Red
Write-Host \"Running cleanup if OneDrive path exists\" -ForegroundColor Red
}
# Check if OneDrive got Uninstalled
if (-not (Test-Path $regPath)) {

# Check if OneDrive got Uninstalled (both paths)
if (Test-Path $OneDrivePath) {
Write-Host \"Copy downloaded Files from the OneDrive Folder to Root UserProfile\"
Start-Process -FilePath powershell -ArgumentList \"robocopy '$($OneDrivePath)' '$($env:USERPROFILE.TrimEnd())\\' /mov /e /xj\" -NoNewWindow -Wait

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

0 comments on commit d49b21f

Please sign in to comment.