forked from ChrisTitusTech/win10script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrestore-ac-tray.ps1
122 lines (103 loc) · 6.32 KB
/
restore-ac-tray.ps1
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# This script restores cortana, action center and tray icons to their out of box state
Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.Application]::EnableVisualStyles()
$ErrorActionPreference = 'SilentlyContinue'
$Button = [System.Windows.MessageBoxButton]::YesNoCancel
$ErrorIco = [System.Windows.MessageBoxImage]::Error
$Ask = 'Do you want to run this as an Administrator?
Select "Yes" to Run as an Administrator
Select "No" to not run this as an Administrator
Select "Cancel" to stop the script.'
If (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]'Administrator')) {
$Prompt = [System.Windows.MessageBox]::Show($Ask, "Run as an Administrator or not?", $Button, $ErrorIco)
Switch ($Prompt) {
#This will debloat Windows 10
Yes {
Write-Host "You didn't run this script as an Administrator. This script will self elevate to run as an Administrator and continue."
Start-Process PowerShell.exe -ArgumentList ("-NoProfile -ExecutionPolicy Bypass -File `"{0}`"" -f $PSCommandPath) -Verb RunAs
Exit
}
No {
Break
}
}
}
Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.Application]::EnableVisualStyles()
$Form = New-Object system.Windows.Forms.Form
$Form.ClientSize = New-Object System.Drawing.Point(804,708)
$Form.text = "CTT Restore Scripts"
$Form.TopMost = $false
$PictureBox1 = New-Object system.Windows.Forms.PictureBox
$PictureBox1.width = 600
$PictureBox1.height = 45
$PictureBox1.location = New-Object System.Drawing.Point(103,23)
$PictureBox1.imageLocation = "https://raw.githubusercontent.com/ChrisTitusTech/win10script/master/ctt-restore-scripts.png"
$PictureBox1.SizeMode = [System.Windows.Forms.PictureBoxSizeMode]::zoom
$EActionCenter = New-Object system.Windows.Forms.Button
$EActionCenter.text = "Enable Action Center"
$EActionCenter.width = 200
$EActionCenter.height = 30
$EActionCenter.location = New-Object System.Drawing.Point(43,106)
$EActionCenter.Font = New-Object System.Drawing.Font('Microsoft Sans Serif',10)
$ECortana = New-Object system.Windows.Forms.Button
$ECortana.text = "Enable Cortana"
$ECortana.width = 200
$ECortana.height = 30
$ECortana.location = New-Object System.Drawing.Point(43,156)
$ECortana.Font = New-Object System.Drawing.Font('Microsoft Sans Serif',10)
$HTrayIcons = New-Object system.Windows.Forms.Button
$HTrayIcons.text = "Hide Tray Icons"
$HTrayIcons.width = 200
$HTrayIcons.height = 30
$HTrayIcons.location = New-Object System.Drawing.Point(407,106)
$HTrayIcons.Font = New-Object System.Drawing.Font('Microsoft Sans Serif',10)
$EClipboardHistory = New-Object system.Windows.Forms.Button
$EClipboardHistory.text = "Enable Clipboard History"
$EClipboardHistory.width = 200
$EClipboardHistory.height = 30
$EClipboardHistory.location = New-Object System.Drawing.Point(407,157)
$EClipboardHistory.Font = New-Object System.Drawing.Font('Microsoft Sans Serif',10)
$RWDIcon = New-Object system.Windows.Forms.Button
$RWDIcon.text = "Restore Windows Defender Icon"
$RWDIcon.width = 200
$RWDIcon.height = 45
$RWDIcon.location = New-Object System.Drawing.Point(43,204)
$RWDIcon.Font = New-Object System.Drawing.Font('Microsoft Sans Serif',10)
$Form.controls.AddRange(@($PictureBox1,$EActionCenter,$ECortana,$HTrayIcons,$EClipboardHistory,$RWDIcon))
$EActionCenter.Add_Click({
Write-Host "Enabling Action Center..."
Remove-ItemProperty -Path "HKCU:\SOFTWARE\Policies\Microsoft\Windows\Explorer" -Name "DisableNotificationCenter" -ErrorAction SilentlyContinue
Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\PushNotifications" -Name "ToastEnabled" -ErrorAction SilentlyContinue
Write-Host "Done - Reverted to Stock Settings"
})
$ECortana.Add_Click({
Write-Host "Enabling Cortana..."
Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Personalization\Settings" -Name "AcceptedPrivacyPolicy" -ErrorAction SilentlyContinue
If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore")) {
New-Item -Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore" -Force | Out-Null
}
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization" -Name "RestrictImplicitTextCollection" -Type DWord -Value 0
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization" -Name "RestrictImplicitInkCollection" -Type DWord -Value 0
Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore" -Name "HarvestContacts" -ErrorAction SilentlyContinue
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name "AllowCortana" -ErrorAction SilentlyContinue
Write-Host "Done - Reverted to Stock Settings"
})
$RWDIcon.Add_Click({
Write-Host "Restoring Windows Defender Icon..."
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" -Name "SecurityHealth" -Type ExpandString -Value "%windir%\system32\SecurityHealthSystray.exe"
Write-Host "Done - Reverted to Stock Settings"
})
$HTrayIcons.Add_Click({
$ErrorActionPreference = 'SilentlyContinue'
Write-Host "Hiding tray icons..."
Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer" -Name "EnableAutoTray" -ErrorAction SilentlyContinue
Write-Host "Done - Reverted to Stock Settings"
})
$EClipboardHistory.Add_Click({
Write-Host "Restoring Clipboard History..."
Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Clipboard" -Name "EnableClipboardHistory" -ErrorAction SilentlyContinue
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Name "AllowClipboardHistory" -ErrorAction SilentlyContinue
Write-Host "Done - Reverted to Stock Settings"
})
[void]$Form.ShowDialog()