mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-01-16 18:00:37 -06:00
Add Reg key to Cleanup and Errorhandling
This commit is contained in:
parent
23bdfbded0
commit
d01448ba08
@ -2451,10 +2451,17 @@
|
|||||||
"
|
"
|
||||||
$OneDrivePath = $($env:OneDrive)
|
$OneDrivePath = $($env:OneDrive)
|
||||||
Write-Host \"Removing OneDrive\"
|
Write-Host \"Removing OneDrive\"
|
||||||
$regPath = \"HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OneDriveSetup.exe\"
|
$regPath = \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OneDriveSetup.exe\"
|
||||||
$OneDriveUninstallString = Get-ItemPropertyValue \"Registry::$regPath\" -Name \"UninstallString\"
|
if (Test-Path $regPath){
|
||||||
|
$OneDriveUninstallString = Get-ItemPropertyValue \"$regPath\" -Name \"UninstallString\"
|
||||||
$OneDriveExe, $OneDriveArgs = $OneDriveUninstallString.Split(\" \")
|
$OneDriveExe, $OneDriveArgs = $OneDriveUninstallString.Split(\" \")
|
||||||
Start-Process -FilePath $OneDriveExe -ArgumentList \"$OneDriveArgs /silent\" -NoNewWindow -Wait
|
Start-Process -FilePath $OneDriveExe -ArgumentList \"$OneDriveArgs /silent\" -NoNewWindow -Wait
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Write-Host \"Onedrive dosn't seem to be installed anymore\" -ForegroundColor Red
|
||||||
|
return
|
||||||
|
}
|
||||||
|
# Check if OneDrive got Uninstalled
|
||||||
if (-not (Test-Path $regPath)){
|
if (-not (Test-Path $regPath)){
|
||||||
Write-Host \"Copy downloaded Files from the OneDrive Folder to Root UserProfile\"
|
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
|
Start-Process -FilePath powershell -ArgumentList \"robocopy '$($OneDrivePath)' '$($env:USERPROFILE.TrimEnd())\\' /mov /e /xj\" -NoNewWindow -Wait
|
||||||
@ -2464,6 +2471,7 @@
|
|||||||
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue \"$env:localappdata\\OneDrive\"
|
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue \"$env:localappdata\\OneDrive\"
|
||||||
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue \"$env:programdata\\Microsoft OneDrive\"
|
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue \"$env:programdata\\Microsoft OneDrive\"
|
||||||
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue \"$env:systemdrive\\OneDriveTemp\"
|
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue \"$env:systemdrive\\OneDriveTemp\"
|
||||||
|
reg delete \"HKEY_CURRENT_USER\\Software\\Microsoft\\OneDrive\" -f
|
||||||
# check if directory is empty before removing:
|
# check if directory is empty before removing:
|
||||||
If ((Get-ChildItem \"$OneDrivePath\" -Recurse | Measure-Object).Count -eq 0) {
|
If ((Get-ChildItem \"$OneDrivePath\" -Recurse | Measure-Object).Count -eq 0) {
|
||||||
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue \"$OneDrivePath\"
|
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue \"$OneDrivePath\"
|
||||||
|
Loading…
Reference in New Issue
Block a user