diff --git a/config/tweaks.json b/config/tweaks.json index ab9dd6ee..f6dbac00 100644 --- a/config/tweaks.json +++ b/config/tweaks.json @@ -1885,42 +1885,6 @@ } ] }, - "WPFMiscTweaksLapPower": { - "registry": [ - { - "Path": "HKLM:\\SYSTEM\\CurrentControlSet\\Control\\Power\\PowerThrottling", - "Name": "PowerThrottlingOff", - "Type": "DWord", - "Value": "00000000", - "OriginalValue": "00000001" - }, - { - "Path": "HKLM:\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Power", - "Name": "HiberbootEnabled", - "Type": "DWord", - "Value": "0000001", - "OriginalValue": "0000000" - } - ] - }, - "WPFMiscTweaksPower": { - "registry": [ - { - "Path": "HKLM:\\SYSTEM\\CurrentControlSet\\Control\\Power\\PowerThrottling", - "Name": "PowerThrottlingOff", - "Type": "DWord", - "Value": "00000001", - "OriginalValue": "00000000" - }, - { - "Path": "HKLM:\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Power", - "Name": "HiberbootEnabled", - "Type": "DWord", - "Value": "0000000", - "OriginalValue": "00000001" - } - ] - }, "WPFMiscTweaksExt": { "registry": [ { @@ -2220,17 +2184,6 @@ " ] }, - "WPFMiscTweaksDisableTPMCheck": { - "registry": [ - { - "Path": "HKLM:\\SYSTEM\\Setup\\MoSetup", - "Name": "AllowUpgradesWithUnsupportedTPM", - "Type": "DWord", - "Value": "1", - "OriginalValue": "0" - } - ] - }, "WPFMiscTweaksDisableUAC": { "registry": [ { @@ -2309,15 +2262,6 @@ Get-ChildItem -Path $env:TEMP *.* -Recurse | Remove-Item -Force -Recurse" ] }, - "WPFEssTweaksRemoveCortana": { - "InvokeScript": [ - "Get-AppxPackage -allusers Microsoft.549981C3F5F10 | Remove-AppxPackage" - ], - "UndoScript": [ - "Get-AppxPackage -allusers | where Name -like \"Microsoft.549981C3F5F10\" | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register \"$($_.InstallLocation)\\AppXManifest.xml\"} - " - ] - }, "WPFEssTweaksDVR": { "registry": [ { diff --git a/functions/private/Remove-OneDrive.ps1 b/functions/private/Remove-OneDrive.ps1 new file mode 100644 index 00000000..12dc6715 --- /dev/null +++ b/functions/private/Remove-OneDrive.ps1 @@ -0,0 +1,85 @@ +function Remove-OneDrive { + <# + + .DESCRIPTION + This function will remove onedrive + + .EXAMPLE + + Remove-OneDrive + + #> + param ( + $name = "OneDrive" + ) + + Try{ + + Write-Output "Kill OneDrive process" + taskkill.exe /F /IM "OneDrive.exe" + taskkill.exe /F /IM "explorer.exe" + + Write-Output "Copy all OneDrive to Root UserProfile" + robocopy $env:USERPROFILE\OneDrive $env:USERPROFILE /e /xj + + Write-Output "Remove OneDrive" + if (Test-Path "$env:systemroot\System32\OneDriveSetup.exe") { + & "$env:systemroot\System32\OneDriveSetup.exe" /uninstall + } + if (Test-Path "$env:systemroot\SysWOW64\OneDriveSetup.exe") { + & "$env:systemroot\SysWOW64\OneDriveSetup.exe" /uninstall + } + + Write-Output "Removing OneDrive leftovers" + Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "$env:localappdata\Microsoft\OneDrive" + Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "$env:programdata\Microsoft OneDrive" + Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "$env:systemdrive\OneDriveTemp" + # check if directory is empty before removing: + If ((Get-ChildItem "$env:userprofile\OneDrive" -Recurse | Measure-Object).Count -eq 0) { + Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "$env:userprofile\OneDrive" + } + + Write-Output "Disable OneDrive via Group Policies" + New-FolderForced -Path "HKLM:\SOFTWARE\Wow6432Node\Policies\Microsoft\Windows\OneDrive" + Set-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Policies\Microsoft\Windows\OneDrive" "DisableFileSyncNGSC" 1 + + Write-Output "Remove Onedrive from explorer sidebar" + New-PSDrive -PSProvider "Registry" -Root "HKEY_CLASSES_ROOT" -Name "HKCR" + mkdir -Force "HKCR:\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" + Set-ItemProperty -Path "HKCR:\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" "System.IsPinnedToNameSpaceTree" 0 + mkdir -Force "HKCR:\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" + Set-ItemProperty -Path "HKCR:\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" "System.IsPinnedToNameSpaceTree" 0 + Remove-PSDrive "HKCR" + + # Thank you Matthew Israelsson + Write-Output "Removing run hook for new users" + reg load "hku\Default" "C:\Users\Default\NTUSER.DAT" + reg delete "HKEY_USERS\Default\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v "OneDriveSetup" /f + reg unload "hku\Default" + + Write-Output "Removing startmenu entry" + Remove-Item -Force -ErrorAction SilentlyContinue "$env:userprofile\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\OneDrive.lnk" + + Write-Output "Removing scheduled task" + Get-ScheduledTask -TaskPath '\' -TaskName 'OneDrive*' -ea SilentlyContinue | Unregister-ScheduledTask -Confirm:$false + + Write-Output "Restarting explorer" + Start-Process "explorer.exe" + + Write-Output "Waiting for explorer to complete loading" + Start-Sleep 10 + } + Catch [System.Exception] { + if($psitem.Exception.Message -like "*The requested operation requires elevation*"){ + Write-Warning "Unable to uninstall $name due to a Security Exception" + } + Else{ + Write-Warning "Unable to uninstall $name due to unhandled exception" + Write-Warning $psitem.Exception.StackTrace + } + } + Catch{ + Write-Warning "Unable to uninstall $name due to unhandled exception" + Write-Warning $psitem.Exception.StackTrace + } +} \ No newline at end of file diff --git a/winutil.ps1 b/winutil.ps1 index 7bab20ea..61cb8526 100644 --- a/winutil.ps1 +++ b/winutil.ps1 @@ -652,6 +652,91 @@ function Invoke-WinUtilTweaks { } } +function Remove-OneDrive { + <# + + .DESCRIPTION + This function will remove onedrive + + .EXAMPLE + + Remove-OneDrive + + #> + param ( + $name = "OneDrive" + ) + + Try{ + + Write-Output "Kill OneDrive process" + taskkill.exe /F /IM "OneDrive.exe" + taskkill.exe /F /IM "explorer.exe" + + Write-Output "Copy all OneDrive to Root UserProfile" + robocopy $env:USERPROFILE\OneDrive $env:USERPROFILE /e /xj + + Write-Output "Remove OneDrive" + if (Test-Path "$env:systemroot\System32\OneDriveSetup.exe") { + & "$env:systemroot\System32\OneDriveSetup.exe" /uninstall + } + if (Test-Path "$env:systemroot\SysWOW64\OneDriveSetup.exe") { + & "$env:systemroot\SysWOW64\OneDriveSetup.exe" /uninstall + } + + Write-Output "Removing OneDrive leftovers" + Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "$env:localappdata\Microsoft\OneDrive" + Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "$env:programdata\Microsoft OneDrive" + Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "$env:systemdrive\OneDriveTemp" + # check if directory is empty before removing: + If ((Get-ChildItem "$env:userprofile\OneDrive" -Recurse | Measure-Object).Count -eq 0) { + Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "$env:userprofile\OneDrive" + } + + Write-Output "Disable OneDrive via Group Policies" + New-FolderForced -Path "HKLM:\SOFTWARE\Wow6432Node\Policies\Microsoft\Windows\OneDrive" + Set-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Policies\Microsoft\Windows\OneDrive" "DisableFileSyncNGSC" 1 + + Write-Output "Remove Onedrive from explorer sidebar" + New-PSDrive -PSProvider "Registry" -Root "HKEY_CLASSES_ROOT" -Name "HKCR" + mkdir -Force "HKCR:\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" + Set-ItemProperty -Path "HKCR:\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" "System.IsPinnedToNameSpaceTree" 0 + mkdir -Force "HKCR:\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" + Set-ItemProperty -Path "HKCR:\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" "System.IsPinnedToNameSpaceTree" 0 + Remove-PSDrive "HKCR" + + # Thank you Matthew Israelsson + Write-Output "Removing run hook for new users" + reg load "hku\Default" "C:\Users\Default\NTUSER.DAT" + reg delete "HKEY_USERS\Default\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v "OneDriveSetup" /f + reg unload "hku\Default" + + Write-Output "Removing startmenu entry" + Remove-Item -Force -ErrorAction SilentlyContinue "$env:userprofile\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\OneDrive.lnk" + + Write-Output "Removing scheduled task" + Get-ScheduledTask -TaskPath '\' -TaskName 'OneDrive*' -ea SilentlyContinue | Unregister-ScheduledTask -Confirm:$false + + Write-Output "Restarting explorer" + Start-Process "explorer.exe" + + Write-Output "Waiting for explorer to complete loading" + Start-Sleep 10 + } + Catch [System.Exception] { + if($psitem.Exception.Message -like "*The requested operation requires elevation*"){ + Write-Warning "Unable to uninstall $name due to a Security Exception" + } + Else{ + Write-Warning "Unable to uninstall $name due to unhandled exception" + Write-Warning $psitem.Exception.StackTrace + } + } + Catch{ + Write-Warning "Unable to uninstall $name due to unhandled exception" + Write-Warning $psitem.Exception.StackTrace + } +} function Remove-WinUtilAPPX { <# @@ -2565,8 +2650,6 @@ $inputXML = '