Browse Source

add optimize windows explorer

pull/9/merge
Alex Hirsch 9 years ago
parent
commit
91e6f00a96
  1. 17
      lib/reg-helper.psm1
  2. 18
      scripts/optimize-windows-explorer.ps1

17
lib/reg-helper.psm1

@ -10,11 +10,24 @@ function Import-Registry($reg) {
}
function Takeown-Registry($key) {
# TODO works only for LocalMachine for now
# TODO does not work for all root keys yet
switch ($key.split('\')[0]) {
"HKEY_CLASSES_ROOT" {
$reg = [Microsoft.Win32.Registry]::ClassesRoot
$key = $key.substring(18)
}
"HKEY_CURRENT_USER" {
$reg = [Microsoft.Win32.Registry]::CurrentUser
$key = $key.substring(18)
}
"HKEY_LOCAL_MACHINE" {
$reg = [Microsoft.Win32.Registry]::LocalMachine
$key = $key.substring(19)
}
}
# set owner
$key = [Microsoft.Win32.Registry]::LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows Defender\Spynet", "ReadWriteSubTree", "TakeOwnership")
$key = $reg.OpenSubKey($key, "ReadWriteSubTree", "TakeOwnership")
$owner = [Security.Principal.NTAccount]"Administrators"
$acl = $key.GetAccessControl()
$acl.SetOwner($owner)

18
scripts/remove-user-folders-under-this-pc.ps1 → scripts/optimize-windows-explorer.ps1

@ -5,6 +5,24 @@
Import-Module -DisableNameChecking $PSScriptRoot\..\lib\reg-helper.psm1
echo "Elevating priviledges for this process"
do {} until (Elevate-Privileges SeTakeOwnershipPrivilege)
echo "Setting default view to This PC"
Import-Registry(@"
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]
"LaunchTo"=dword:00000000
"@)
# Explorer will throw an error if quick acess is removed but the default view
# has not been changed to This PC.
echo "Removing Quick Access from explorer"
Takeown-Registry("HKEY_CLASSES_ROOT\CLSID\{679f85cb-0220-4080-b29b-5540cc05aab6}\ShellFolder")
Import-Registry(@"
[HKEY_CLASSES_ROOT\CLSID\{679f85cb-0220-4080-b29b-5540cc05aab6}\ShellFolder]
"Attributes"=dword:a0600000
"@)
echo "Removing user folders under This PC"
Import-Registry(@"
; Remove Desktop From This PC
Loading…
Cancel
Save