Skip to content

Commit 27c0e08

Browse files
authoredDec 5, 2020
Update restore-ac-tray.ps1
Add Enable Location, Restore Windows Search and Enable Background Apps
1 parent d6bc260 commit 27c0e08

File tree

1 file changed

+69
-6
lines changed

1 file changed

+69
-6
lines changed
 

‎restore-ac-tray.ps1

+69-6
Original file line numberDiff line numberDiff line change
@@ -46,38 +46,59 @@ $EActionCenter = New-Object system.Windows.Forms.Button
4646
$EActionCenter.text = "Enable Action Center"
4747
$EActionCenter.width = 200
4848
$EActionCenter.height = 30
49-
$EActionCenter.location = New-Object System.Drawing.Point(43,106)
49+
$EActionCenter.location = New-Object System.Drawing.Point(43,99)
5050
$EActionCenter.Font = New-Object System.Drawing.Font('Microsoft Sans Serif',10)
5151

5252
$ECortana = New-Object system.Windows.Forms.Button
5353
$ECortana.text = "Enable Cortana"
5454
$ECortana.width = 200
5555
$ECortana.height = 30
56-
$ECortana.location = New-Object System.Drawing.Point(43,156)
56+
$ECortana.location = New-Object System.Drawing.Point(43,153)
5757
$ECortana.Font = New-Object System.Drawing.Font('Microsoft Sans Serif',10)
5858

5959
$HTrayIcons = New-Object system.Windows.Forms.Button
6060
$HTrayIcons.text = "Hide Tray Icons"
6161
$HTrayIcons.width = 200
6262
$HTrayIcons.height = 30
63-
$HTrayIcons.location = New-Object System.Drawing.Point(407,106)
63+
$HTrayIcons.location = New-Object System.Drawing.Point(407,99)
6464
$HTrayIcons.Font = New-Object System.Drawing.Font('Microsoft Sans Serif',10)
6565

6666
$EClipboardHistory = New-Object system.Windows.Forms.Button
6767
$EClipboardHistory.text = "Enable Clipboard History"
6868
$EClipboardHistory.width = 200
6969
$EClipboardHistory.height = 30
70-
$EClipboardHistory.location = New-Object System.Drawing.Point(407,157)
70+
$EClipboardHistory.location = New-Object System.Drawing.Point(407,151)
7171
$EClipboardHistory.Font = New-Object System.Drawing.Font('Microsoft Sans Serif',10)
7272

7373
$RWDIcon = New-Object system.Windows.Forms.Button
7474
$RWDIcon.text = "Restore Windows Defender Icon"
7575
$RWDIcon.width = 200
7676
$RWDIcon.height = 45
77-
$RWDIcon.location = New-Object System.Drawing.Point(43,204)
77+
$RWDIcon.location = New-Object System.Drawing.Point(43,207)
7878
$RWDIcon.Font = New-Object System.Drawing.Font('Microsoft Sans Serif',10)
7979

80-
$Form.controls.AddRange(@($PictureBox1,$EActionCenter,$ECortana,$HTrayIcons,$EClipboardHistory,$RWDIcon))
80+
$ELocation = New-Object system.Windows.Forms.Button
81+
$ELocation.text = "Enable Location"
82+
$ELocation.width = 200
83+
$ELocation.height = 30
84+
$ELocation.location = New-Object System.Drawing.Point(407,215)
85+
$ELocation.Font = New-Object System.Drawing.Font('Microsoft Sans Serif',10)
86+
87+
$RWindowsSearch = New-Object system.Windows.Forms.Button
88+
$RWindowsSearch.text = "Restore Windows Search"
89+
$RWindowsSearch.width = 200
90+
$RWindowsSearch.height = 45
91+
$RWindowsSearch.location = New-Object System.Drawing.Point(43,276)
92+
$RWindowsSearch.Font = New-Object System.Drawing.Font('Microsoft Sans Serif',10)
93+
94+
$RBackgroundApps = New-Object system.Windows.Forms.Button
95+
$RBackgroundApps.text = "Restore Background Apps"
96+
$RBackgroundApps.width = 200
97+
$RBackgroundApps.height = 45
98+
$RBackgroundApps.location = New-Object System.Drawing.Point(407,279)
99+
$RBackgroundApps.Font = New-Object System.Drawing.Font('Microsoft Sans Serif',10)
100+
101+
$Form.controls.AddRange(@($PictureBox1,$EActionCenter,$ECortana,$HTrayIcons,$EClipboardHistory,$RWDIcon,$ELocation,$RWindowsSearch,$RBackgroundApps))
81102

82103
$EActionCenter.Add_Click({
83104
Write-Host "Enabling Action Center..."
@@ -105,6 +126,19 @@ $RWDIcon.Add_Click({
105126
Write-Host "Done - Reverted to Stock Settings"
106127
})
107128

129+
$RWindowsSearch.Add_Click({
130+
Write-Host "Restoring Windows Search..."
131+
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" -Name "BingSearchEnabled" -Type DWord -Value "1"
132+
Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" -Name "CortanaConsent" -ErrorAction SilentlyContinue
133+
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name "DisableWebSearch" -ErrorAction SilentlyContinue
134+
Write-Host "Restore and Starting Windows Search Service..."
135+
Set-Service "WSearch" -StartupType Automatic
136+
Start-Service "WSearch" -WarningAction SilentlyContinue
137+
Write-Host "Restore Windows Search Icon..."
138+
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" -Name "SearchboxTaskbarMode" -Type DWord -Value 1
139+
Write-Host "Done - Reverted to Stock Settings"
140+
})
141+
108142
$HTrayIcons.Add_Click({
109143
$ErrorActionPreference = 'SilentlyContinue'
110144
Write-Host "Hiding tray icons..."
@@ -119,4 +153,33 @@ $EClipboardHistory.Add_Click({
119153
Write-Host "Done - Reverted to Stock Settings"
120154
})
121155

156+
$ELocation.Add_Click({
157+
Write-Host "Enabling Location Provider..."
158+
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\LocationAndSensors" -Name "DisableWindowsLocationProvider" -ErrorAction SilentlyContinue
159+
Write-Host "Enabling Location Scripting..."
160+
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\LocationAndSensors" -Name "DisableLocationScripting" -ErrorAction SilentlyContinue
161+
Write-Host "Enabling Location..."
162+
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\LocationAndSensors" -Name "DisableLocation" -ErrorAction SilentlyContinue
163+
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Sensor\Overrides\{BFA794E4-F964-4FDB-90F6-51056BFE4B44}" -Name "SensorPermissionState" -ErrorAction SilentlyContinue
164+
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{BFA794E4-F964-4FDB-90F6-51056BFE4B44}" -Name "Value" -Type String -Value "Allow"
165+
Write-Host "Allow access to Location..."
166+
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\location" -Name "Value" -Type String -Value "Allow"
167+
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\lfsvc\Service\Configuration" -Name "Status" -Type DWord -Value "1"
168+
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" -Name "LetAppsAccessLocation" -ErrorAction SilentlyContinue
169+
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" -Name "LetAppsAccessLocation_UserInControlOfTheseApps" -ErrorAction SilentlyContinue
170+
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" -Name "LetAppsAccessLocation_ForceAllowTheseApps" -ErrorAction SilentlyContinue
171+
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" -Name "LetAppsAccessLocation_ForceDenyTheseApps" -ErrorAction SilentlyContinue
172+
Write-Host "Done - Reverted to Stock Settings"
173+
})
174+
175+
$RBackgroundApps.Add_Click({
176+
Write-Host "Allowing Background Apps..."
177+
Get-ChildItem -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\BackgroundAccessApplications" -Exclude "Microsoft.Windows.Cortana*" | ForEach {
178+
Remove-ItemProperty -Path $_.PsPath -Name "Disabled" -ErrorAction SilentlyContinue
179+
Remove-ItemProperty -Path $_.PsPath -Name "DisabledByUser" -ErrorAction SilentlyContinue
180+
}
181+
Write-Host "Done - Reverted to Stock Settings"
182+
})
183+
184+
122185
[void]$Form.ShowDialog()

0 commit comments

Comments
 (0)
Please sign in to comment.