Cleaning up Windows Explorer

By YellowOnline on Monday 26 February 2018 18:50 - Comments (9)
Category: Powershell, Views: 4.891

Do you hate the default Windows shortcuts in Windows Explorer as much as I do, yet you don't want to switch to Total Commander for some reason? Here's a little script I wrote in Powershell to get a clean layout like this:


https://tweakers.net/ext/f/7v6Zll7DEL2UcLYAEoaWc3dl/full.png

There are several how-to's on the net to remove single objects, whether through executing a registry file or by accessing the registry directly. Often the latter, as some settings can only be changed by TrustedInstaller. This script uses a real hack that I probably shouldn't share in the first place, courtesy of tirannido, to impersonate TrustedInstaller and subsequently edit the registry - which is not only more practical than manually taking ownership but also cleaner and therefore safer in the long run.




It was tested with a vanilla VM and works perfectly. Unfortunately the registry tweaks don't have any effect on my own system, but I've messed around with it so much that I can't say I'm surprised about that. It's not representative.



PowerShell:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#Requires -RunAsAdministrator
#By YellowOnline, 20180226

#Dependency to hack the ACL
Install-Module -Name NtObjectManager 

#Thank you https://tyranidslair.blogspot.de/2017/08/the-art-of-becoming-trustedinstaller.html
Start-Service TrustedInstaller
$objProcess = Get-NTProcess -Name TrustedInstaller.exe
$objThread = $objProcess.GetFirstThread()
$objCurrentThread = Get-NTThread -Current -PseudoHandle
$objImpersonatedThread = $objCurrentThread.impersonatethread($objThread)
$objImpersonatedThread_token = Get-NTToken -Impersonation
$objImpersonatedThread_token.groups | Where-Object {$Sid.name -match "TrustedInstaller"}

#Time for some registry editing
New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT

#Change default Launch To to My Computer instead of Quick Access
Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced'  -Name 'LaunchTo' -Value '1'  -Type DWord 

#Remove Quick Access
Set-ItemProperty -Path 'HKCR:\CLSID\{679F85CB-0220-4080-B29B-5540CC05AAB6}\ShellFolder' -Name 'Attributes' -Value '2690646016' -Type DWord
Set-ItemProperty -Path 'HKCR:\Wow6432Node\CLSID\{679F85CB-0220-4080-B29B-5540CC05AAB6}\ShellFolder' -Name 'Attributes' -Value '2690646016' -Type DWord

#Remove OneDrive
Set-ItemProperty -Path 'HKCR:\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}' -Name 'System.IsPinnedToNameSpaceTree' -Value '0' -Type DWord
Set-ItemProperty -Path 'HKCR:\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}' -Name 'System.IsPinnedToNameSpaceTree' -Value '0' -Type DWord

#Remove User Folder
Set-ItemProperty -Path 'HKCU:\Software\Classes\CLSID\{59031A47-3F72-44A7-89C5-5595FE6B30EE}' -Name 'System.IsPinnedToNameSpaceTree' -Value '0' -Type DWord

#Remove 3D Objects
Remove-Item -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}' -Recurse
Remove-Item -Path 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}' -Recurse

#Remove Libraries
Set-ItemProperty -Path 'HKCU:\Software\Classes\CLSID\{031E4825-7B94-4DC3-B131-E946B44C8DD5}' -Name 'System.IsPinnedToNameSpaceTree' -Value '0' -Type DWord

#Remove This PC\Desktop
Remove-Item -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}' -Recurse
Remove-Item -Path 'HKLM:SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}' -Recurse

#Remove This PC\Documents
Remove-Item -Path 'HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{A8CDFF1C-4878-43be-B5FD-F8091C1C60D0}' -Recurse
Remove-Item -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{d3162b92-9365-467a-956b-92703aca08af}' -Recurse
Remove-Item -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{A8CDFF1C-4878-43be-B5FD-F8091C1C60D0}' -Recurse
Remove-Item -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{d3162b92-9365-467a-956b-92703aca08af}' -Recurse

#Remove This PC\Downloads
Remove-Item -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{374DE290-123F-4565-9164-39C4925E467B}' -Recurse
Remove-Item -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{088e3905-0323-4b02-9826-5d99428e115f}' -Recurse
Remove-Item -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{374DE290-123F-4565-9164-39C4925E467B}' -Recurse
Remove-Item -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{088e3905-0323-4b02-9826-5d99428e115f}' -Recurse

#Remove This PC\Music
Remove-Item -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{1CF1260C-4DD0-4ebb-811F-33C572699FDE}' -Recurse
Remove-Item -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{3dfdf296-dbec-4fb4-81d1-6a3438bcf4de}' -Recurse
Remove-Item -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{1CF1260C-4DD0-4ebb-811F-33C572699FDE}' -Recurse
Remove-Item -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{3dfdf296-dbec-4fb4-81d1-6a3438bcf4de}' -Recurse

#Remove This PC\Pictures
Remove-Item -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{3ADD1653-EB32-4cb0-BBD7-DFA0ABB5ACCA}' -Recurse
Remove-Item -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{24ad3ad4-a569-4530-98e1-ab02f9417aa8}' -Recurse
Remove-Item -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{3ADD1653-EB32-4cb0-BBD7-DFA0ABB5ACCA}' -Recurse
Remove-Item -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{24ad3ad4-a569-4530-98e1-ab02f9417aa8}' -Recurse

#Remove This PC\Videos
Remove-Item -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{A0953C92-50DC-43bf-BE83-3742FED03C9C}' -Recurse
Remove-Item -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{f86fa3ab-70d2-4fc7-9c99-fcbf05467f3a}' -Recurse
Remove-Item -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{A0953C92-50DC-43bf-BE83-3742FED03C9C}' -Recurse
Remove-Item -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{f86fa3ab-70d2-4fc7-9c99-fcbf05467f3a}' -Recurse

# Remove double drives
Remove-Item -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\DelegateFolders\{F5FB2C77-0E2F-4A16-A381-3E560C68BC83}' -Recurse
Remove-Item -Path 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\DelegateFolders\{F5FB2C77-0E2F-4A16-A381-3E560C68BC83}' -Recurse

#Remove Network
Set-ItemProperty -Path 'HKCR:\CLSID\{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}' -Name 'System.IsPinnedToNameSpaceTree' -Value '0' -Type DWord
Set-ItemProperty -Path 'HKCR:\Wow6432Node\CLSID\{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}' -Name 'System.IsPinnedToNameSpaceTree' -Value '0' -Type DWord

#Remove Control Panel
Set-ItemProperty -Path 'HKCR:\CLSID\{5399E694-6CE5-4D6C-8FCE-1D8870FDCBA0}' -Name 'System.IsPinnedToNameSpaceTree' -Value '0' -Type DWord
Set-ItemProperty -Path 'HKCR:\Wow6432Node\CLSID\{5399E694-6CE5-4D6C-8FCE-1D8870FDCBA0}' -Name 'System.IsPinnedToNameSpaceTree' -Value '0' -Type DWord

#Remove Recycle Bin
#Mmm, that can stay

Get-Process explorer | Stop-Process -Force
#EOF



Disclaimer
I am not responsible for screwing your interface up.




EDIT
How it looks on my end:

from
https://tweakers.net/ext/f/2wfcm7y0kvTMWS2Ovrruyyvq/full.png

to
https://tweakers.net/ext/f/037YDe7DIfKDOxkku1WiJn50/full.png

Volgende: So how does my own network look? 17-03 So how does my own network look?
Volgende: YellowOnline Mini is nu Beta 17-02 YellowOnline Mini is nu Beta

Comments



By Tweakers user Leonarduz, Monday 26 February 2018 22:56

Nice script, very usefull collection!

By Tweakers user Danny.G, Monday 26 February 2018 22:58

Not that I am planning to use it, but how do you get it back to its original state?

Some might be wondering.. :)

By Tweakers user YellowOnline, Tuesday 27 February 2018 08:21

Danny.G wrote on Monday 26 February 2018 @ 22:58:
Not that I am planning to use it, but how do you get it back to its original state?

Some might be wondering.. :)
Recreate the keys that you deleted, put the System.IsPinnedToNameSpaceTree back to 1 and restore the original value for the Attributes setting :Y)

By Tweakers user Webgnome, Tuesday 27 February 2018 15:21

You do know that that there is a simple 'unpin from quick access' option in windows?

By Tweakers user Satangel, Thursday 1 March 2018 18:16

Nice post!

https://superuser.com/que...business-windows-explorer

Could you help me out with this problem? Been trying it for ages but just won't work!

By Tweakers user YellowOnline, Thursday 1 March 2018 18:25

Satangel wrote on Thursday 1 March 2018 @ 18:16:
Nice post!

https://superuser.com/que...business-windows-explorer

Could you help me out with this problem? Been trying it for ages but just won't work!
Put the value of HKEY_CLASSES_ROOT\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6} System.IsPinnedToNameSpaceTree to 0. If that does not work you can delete the whole key. Export to a file first so you can undo it if necessary.

By Tweakers user LankHoar, Friday 2 March 2018 12:54

Cool. Do you know a way how I can make the wallpaper appear black? Something I've tried in many ways, but never succeeded at so far.

By Tweakers user Damic, Saturday 17 March 2018 18:49

Webgnome wrote on Tuesday 27 February 2018 @ 15:21:
You do know that that there is a simple 'unpin from quick access' option in windows?
Dat kan best zijn, maar dan moet je wel eerst je drives hebben gepinned, en dat is standaard niet.

Comments are closed