-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathset.psm1
4325 lines (3612 loc) · 217 KB
/
set.psm1
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
##########
#region Priority
##########
Function Priority {
$ErrorActionPreference = 'SilentlyContinue'
New-PSDrive -PSProvider Registry -Name HKCU -Root HKEY_CURRENT_USER | Out-Null
New-PSDrive -PSProvider Registry -Name HKLM -Root HKEY_LOCAL_MACHINE | Out-Null
New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS | Out-Null
New-PSDrive -Name "HKCR" -PSProvider "Registry" -Root "HKEY_CLASSES_ROOT" | Out-Null
$ErrorActionPreference = 'SilentlyContinue'
$checkQuickAssist = Get-WindowsCapability -online | where-object { $_.name -like "*QuickAssist*" }
Remove-WindowsCapability -online -name $checkQuickAssist.name -ErrorAction Stop *>$null
Set-ExecutionPolicy RemoteSigned -Force -Scope CurrentUser
$ErrorActionPreference = 'Continue'
}
Priority
Function Silent {
$Global:ProgressPreference = 'SilentlyContinue'
}
##########
#endregion Priority
##########
##########
#region System Settings
##########
Function SystemSettings {
Write-Host "`n---------Adjusting System Settings" -ForegroundColor Blue -BackgroundColor Gray
Write-Host "`nDo you want " -NoNewline
Write-Host "System Settings?" -ForegroundColor Yellow -NoNewline
Write-Host "(y/n): " -ForegroundColor Green -NoNewline
$response = Read-Host
if ($response -eq 'y' -or $response -eq 'Y') {
Function TRFormats {
Write-Host `n"Do you want to " -NoNewline
Write-Host "change the region settings to Turkiye?" -ForegroundColor Yellow -NoNewline
Write-Host "(y/n): " -ForegroundColor Green -NoNewline
$response = Read-Host
if ($response -eq 'y' -or $response -eq 'Y') {
Write-Host "Setting date format of Turkiye..." -NoNewline
try {
Set-TimeZone -Name "Turkey Standard Time" -ErrorAction Stop
Set-Culture tr-TR -ErrorAction Stop
Set-ItemProperty -Path "HKCU:\Control Panel\International" -name ShortDate -value "dd/MM/yyyy" -ErrorAction Stop
#sync time
Set-Service -Name "W32Time" -StartupType Automatic -ErrorAction Stop
Restart-Service W32Time *>$null
if (-not $?) { throw "Failed to stop W32Time" }
w32tm /resync /force *>$null
if (-not $?) { throw "Failed to resync time" }
w32tm /config /manualpeerlist:"time.windows.com" /syncfromflags:manual /reliable:yes /update *>$null
if (-not $?) { throw "Failed to configure time sync settings" }
#set time sync to Cloudflare
w32tm /config /manualpeerlist:"time.cloudflare.com" /syncfromflags:manual /reliable:yes /update *>$null
Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black
}
catch {
Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black
}
}
elseif ($response -eq 'n' -or $response -eq 'N') {
Write-Host "[Turkish region format adjustment has been canceled]" -ForegroundColor Red -BackgroundColor Black
}
else {
Write-Host "Invalid input. Please enter 'y' for yes or 'n' for no."
TRFormats
}
}
TRFormats
Function SetHostname {
Write-Host `n"Do you want " -NoNewline
Write-Host "change your hostname?" -ForegroundColor Yellow -NoNewline
Write-Host "(y/n): " -ForegroundColor Green -NoNewline
$response = Read-Host
if ($response -eq 'y' -or $response -eq 'Y') {
$hostq = Write-Host "Please enter your hostname: " -NoNewline
$hostname = Read-Host -Prompt $hostq
Rename-Computer -NewName "$hostname" *>$null
Write-Host "[Hostname was set to " -NoNewline -BackgroundColor Black
Write-Host "$hostname" -ForegroundColor Green -BackgroundColor Black -NoNewline
Write-Host "]" -BackgroundColor Black
}
elseif ($response -eq 'n' -or $response -eq 'N') {
Write-Host "[Hostname will not be changed]" -ForegroundColor Red -BackgroundColor Black
}
else {
Write-Host "Invalid input. Please enter 'y' for yes or 'n' for no."
SetHostname
}
}
SetHostname
Function DisableDefender {
Write-Host `n"Do you want " -NoNewline
Write-Host "disable Windows Defender?" -ForegroundColor Yellow -NoNewline
Write-Host "(y/n): " -ForegroundColor Green -NoNewline
$response = Read-Host
if ($response -eq 'y' -or $response -eq 'Y') {
Write-Host "Disabling Windows Defender..." -NoNewline
try {
# Disable Defender Cloud
If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet")) {
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Force *>$null
}
# Remove existing policies
Remove-Item -Path "HKLM:\Software\Policies\Microsoft\Windows Defender" -Recurse -ErrorAction SilentlyContinue
# Create new policies
New-Item -Path "HKLM:\Software\Policies\Microsoft\Windows Defender" -Force *>$null
New-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows Defender" -Name "DisableAntiSpyware" -PropertyType Dword -Value "1" *>$null
New-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows Defender" -Name "DisableAntiVirus" -PropertyType Dword -Value "1" *>$null
# Disable Real-Time Protection
New-Item -Path "HKLM:\Software\Policies\Microsoft\Windows Defender\Real-Time Protection" -Force *>$null
New-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows Defender\Real-Time Protection" -Name "DisableBehaviorMonitoring" -PropertyType Dword -Value "1" *>$null
New-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows Defender\Real-Time Protection" -Name "DisableIOAVProtection" -PropertyType Dword -Value "1" *>$null
New-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows Defender\Real-Time Protection" -Name "DisableOnAccessProtection" -PropertyType Dword -Value "1" *>$null
New-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows Defender\Real-Time Protection" -Name "DisableRealtimeMonitoring" -PropertyType Dword -Value "1" *>$null
New-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows Defender\Real-Time Protection" -Name "DisableScanOnRealtimeEnable" -PropertyType Dword -Value "1" *>$null
# Disable Cloud-Based Protection
New-Item -Path "HKLM:\Software\Policies\Microsoft\Windows Defender\Spynet" -Force *>$null
New-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows Defender\Spynet" -Name "DisableBlockAtFirstSeen" -PropertyType Dword -Value "1" *>$null
New-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows Defender\Spynet" -Name "SpynetReporting" -PropertyType Dword -Value "0" *>$null
New-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows Defender\Spynet" -Name "SubmitSamplesConsent" -PropertyType Dword -Value "0" *>$null
# Disable Enhanced Notifications
New-Item -Path "HKLM:\Software\Policies\Microsoft\Windows Defender\Reporting" -Force *>$null
New-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows Defender\Reporting" -Name "DisableEnhancedNotifications" -PropertyType Dword -Value "1" *>$null
# Disable Windows Defender tasks
schtasks /Change /TN "Microsoft\Windows\ExploitGuard\ExploitGuard MDM policy Refresh" /Disable *>$null
schtasks /Change /TN "Microsoft\Windows\Windows Defender\Windows Defender Cache Maintenance" /Disable *>$null
schtasks /Change /TN "Microsoft\Windows\Windows Defender\Windows Defender Cleanup" /Disable *>$null
schtasks /Change /TN "Microsoft\Windows\Windows Defender\Windows Defender Scheduled Scan" /Disable *>$null
schtasks /Change /TN "Microsoft\Windows\Windows Defender\Windows Defender Verification" /Disable *>$null
# Remove Windows Defender context menu entries
New-PSDrive -Name "HKCR" -PSProvider "Registry" -Root "HKEY_CLASSES_ROOT" | Out-Null
Remove-Item -LiteralPath "HKCR:\*\shellex\ContextMenuHandlers\EPP" -ErrorAction SilentlyContinue
Remove-Item -Path "HKCR:\Directory\shellex\ContextMenuHandlers\EPP" -Recurse -ErrorAction SilentlyContinue
Remove-Item -Path "HKCR:\Drive\shellex\ContextMenuHandlers\EPP" -Recurse -ErrorAction SilentlyContinue
# Disable system guard
$systemguardPath = "HKLM:\SYSTEM\CurrentControlSet\Control\DeviceGuard\Scenarios\SystemGuard"
if (-not (Test-Path $systemguardPath)) { New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Control\DeviceGuard\Scenarios" -Name "SystemGuard" -Force *>$null }
New-ItemProperty -Path $systemguardPath -Name "Enabled" -Value 0 -PropertyType DWORD -Force *>$null
# Restart Windows Explorer
taskkill /f /im explorer.exe *>$null
Start-Process "explorer.exe" -NoNewWindow
Start-Sleep 4
Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black
}
catch {
Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black
}
}
elseif ($response -eq 'n' -or $response -eq 'N') {
Write-Host "[Windows Defender will not be disabled]" -ForegroundColor Red -BackgroundColor Black
}
else {
Write-Host "Invalid input. Please enter 'y' for yes or 'n' for no."
DisableDefender
}
}
DisableDefender
Function SetKeyboardLayout {
Write-Host "`nDo you want to " -NoNewline
Write-Host "set the keyboard layout to UK or TR?" -ForegroundColor Yellow -NoNewline
Write-Host "(y/n): " -ForegroundColor Green -NoNewline
$response = Read-Host
if ($response -eq 'y' -or $response -eq 'Y') {
do {
Write-Host "Which keyboard layout do you want to set? Write 1, 2, 3 or 4."
Write-Host `n"[1]" -NoNewline -BackgroundColor Black -ForegroundColor Yellow
Write-Host " - Turkish keyboard layout"
Write-Host "[2]" -NoNewline -BackgroundColor Black -ForegroundColor Yellow
Write-Host " - United Kingdom keyboard layout"
Write-Host "[3]" -NoNewline -BackgroundColor Black -ForegroundColor Yellow
Write-Host " - Both Turkish and United Kingdom keyboard layout"
Write-Host "[4]" -NoNewline -BackgroundColor Black -ForegroundColor Yellow
Write-Host " - None"
$choice = Read-Host -Prompt "`n[Choice]"
$validChoice = $true
switch ($choice) {
"1" {
# TR keyboard layout
New-PSDrive -PSProvider Registry -Name HKCU -Root HKEY_CURRENT_USER | Out-Null
New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS | Out-Null
# Remove all keyboard layouts under HKCU
Get-ItemProperty "HKCU:\Keyboard Layout\Preload" | ForEach-Object {
$_.PSObject.Properties.Name | Where-Object { $_ -ne "PSPath" -and $_ -ne "PSParentPath" -and $_ -ne "PSChildName" -and $_ -ne "PSDrive" -and $_ -ne "PSProvider" } | ForEach-Object {
Remove-ItemProperty -Path "HKCU:\Keyboard Layout\Preload" -Name $_ -ErrorAction SilentlyContinue
}
}
# Remove all keyboard layouts under HKEY_USERS\.DEFAULT
Get-ItemProperty "HKU:\.DEFAULT\Keyboard Layout\Preload" | ForEach-Object {
$_.PSObject.Properties.Name | Where-Object { $_ -ne "PSPath" -and $_ -ne "PSParentPath" -and $_ -ne "PSChildName" -and $_ -ne "PSDrive" -and $_ -ne "PSProvider" } | ForEach-Object {
Remove-ItemProperty -Path "HKU:\.DEFAULT\Keyboard Layout\Preload" -Name $_ -ErrorAction SilentlyContinue
}
}
# Set keyboard layout to TR
Get-ChildItem "HKCU:\Keyboard Layout\Preload", "HKU:\.DEFAULT\Keyboard Layout\Preload" | Remove-ItemProperty -Name * -ErrorAction SilentlyContinue
Set-ItemProperty -Path "HKCU:\Keyboard Layout\Preload" -Name "1" -Value "0000041f"
Set-ItemProperty -Path "HKU:\.DEFAULT\Keyboard Layout\Preload" -Name "1" -Value "0000041f"
Set-WinLanguageBarOption -UseLegacyLanguageBar
#disable different input for each app
Set-WinLanguageBarOption
# Disable Print Screen key for Snipping Tool
Set-ItemProperty -Path "HKCU:\Control Panel\Keyboard" -Name "PrintScreenKeyForSnippingEnabled" -Value 0 *>$null
}
"2" {
# UK keyboard layout
New-PSDrive -PSProvider Registry -Name HKCU -Root HKEY_CURRENT_USER | Out-Null
New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS | Out-Null
# Remove all keyboard layouts under HKCU
Get-ItemProperty "HKCU:\Keyboard Layout\Preload" | ForEach-Object {
$_.PSObject.Properties.Name | Where-Object { $_ -ne "PSPath" -and $_ -ne "PSParentPath" -and $_ -ne "PSChildName" -and $_ -ne "PSDrive" -and $_ -ne "PSProvider" } | ForEach-Object {
Remove-ItemProperty -Path "HKCU:\Keyboard Layout\Preload" -Name $_ -ErrorAction SilentlyContinue
}
}
# Remove all keyboard layouts under HKEY_USERS\.DEFAULT
Get-ItemProperty "HKU:\.DEFAULT\Keyboard Layout\Preload" | ForEach-Object {
$_.PSObject.Properties.Name | Where-Object { $_ -ne "PSPath" -and $_ -ne "PSParentPath" -and $_ -ne "PSChildName" -and $_ -ne "PSDrive" -and $_ -ne "PSProvider" } | ForEach-Object {
Remove-ItemProperty -Path "HKU:\.DEFAULT\Keyboard Layout\Preload" -Name $_ -ErrorAction SilentlyContinue
}
}
# Set keyboard layout to UK
Get-ChildItem "HKCU:\Keyboard Layout\Preload", "HKU:\.DEFAULT\Keyboard Layout\Preload" | Remove-ItemProperty -Name * -ErrorAction SilentlyContinue
Set-ItemProperty -Path "HKCU:\Keyboard Layout\Preload" -Name "1" -Value "00000809"
Set-ItemProperty -Path "HKU:\.DEFAULT\Keyboard Layout\Preload" -Name "1" -Value "00000809"
Set-WinLanguageBarOption -UseLegacyLanguageBar
#disable different input for each app
Set-WinLanguageBarOption
# Disable Print Screen key for Snipping Tool
Set-ItemProperty -Path "HKCU:\Control Panel\Keyboard" -Name "PrintScreenKeyForSnippingEnabled" -Value 0 *>$null
}
"3" {
# Both TR and UK keyboard layout
New-PSDrive -PSProvider Registry -Name HKCU -Root HKEY_CURRENT_USER | Out-Null
New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS | Out-Null
# Remove all keyboard layouts under HKCU
Get-ItemProperty "HKCU:\Keyboard Layout\Preload" | ForEach-Object {
$_.PSObject.Properties.Name | Where-Object { $_ -ne "PSPath" -and $_ -ne "PSParentPath" -and $_ -ne "PSChildName" -and $_ -ne "PSDrive" -and $_ -ne "PSProvider" } | ForEach-Object {
Remove-ItemProperty -Path "HKCU:\Keyboard Layout\Preload" -Name $_ -ErrorAction SilentlyContinue
}
}
# Remove all keyboard layouts under HKEY_USERS\.DEFAULT
Get-ItemProperty "HKU:\.DEFAULT\Keyboard Layout\Preload" | ForEach-Object {
$_.PSObject.Properties.Name | Where-Object { $_ -ne "PSPath" -and $_ -ne "PSParentPath" -and $_ -ne "PSChildName" -and $_ -ne "PSDrive" -and $_ -ne "PSProvider" } | ForEach-Object {
Remove-ItemProperty -Path "HKU:\.DEFAULT\Keyboard Layout\Preload" -Name $_ -ErrorAction SilentlyContinue
}
}
# Set keyboard layout to TR and UK
Get-ChildItem "HKCU:\Keyboard Layout\Preload", "HKU:\.DEFAULT\Keyboard Layout\Preload" | Remove-ItemProperty -Name * -ErrorAction SilentlyContinue
Set-ItemProperty -Path "HKCU:\Keyboard Layout\Preload" -Name "1" -Value "00000809"
Set-ItemProperty -Path "HKCU:\Keyboard Layout\Preload" -Name "2" -Value "0000041f"
Set-ItemProperty -Path "HKU:\.DEFAULT\Keyboard Layout\Preload" -Name "1" -Value "00000809"
Set-ItemProperty -Path "HKU:\.DEFAULT\Keyboard Layout\Preload" -Name "2" -Value "0000041f"
Set-WinLanguageBarOption -UseLegacyLanguageBar
#disable different input for each app
Set-WinLanguageBarOption
# Disable Print Screen key for Snipping Tool
Set-ItemProperty -Path "HKCU:\Control Panel\Keyboard" -Name "PrintScreenKeyForSnippingEnabled" -Value 0 *>$null
}
"4" {
Write-Host "[No changes will be made to the keyboard layout.]" -ForegroundColor Red -BackgroundColor Black
}
default {
Write-Host "Invalid input. Please enter 1, 2, 3 or 4."
$validChoice = $false
}
}
} while (-not $validChoice)
}
elseif ($response -eq 'n' -or $response -eq 'N') {
Write-Host "[Keyboard layout will not be changed.]" -ForegroundColor Red -BackgroundColor Black
}
else {
Write-Host "[Invalid input. Please enter 'y' for yes or 'n' for no.]" -ForegroundColor Red -BackgroundColor Black
SetKeyboardLayout
}
}
SetKeyboardLayout
Function ImportStartup {
Write-Host `n"For detailed information > " -NoNewline
Write-Host "https://github.com/caglaryalcin/after-format#description" -ForegroundColor DarkCyan
Write-Host "Do you want to " -NoNewline
Write-Host "add the start task to the task scheduler?" -ForegroundColor Yellow -NoNewline
Write-Host "(y/n): " -ForegroundColor Green -NoNewline
$response = Read-Host
if ($response -eq 'y' -or $response -eq 'Y') {
Write-Host "Importing Startup task in Task Scheduler..." -NoNewline
#upgrade
$action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-ExecutionPolicy Bypass -WindowStyle Hidden -Command `"`winget upgrade --all`""
$trigger = New-ScheduledTaskTrigger -AtStartup
$settings = New-ScheduledTaskSettingsSet -Hidden:$true
$description = "You can check all the operations of this project at this link. https://github.com/caglaryalcin/after-format"
$principal = New-ScheduledTaskPrincipal -GroupId "S-1-5-32-544" -RunLevel Highest
$taskname = "upgrade-packages"
$delay = "PT1M" # 1 minutes delay
$trigger.Delay = $delay
Register-ScheduledTask -Action $action -Trigger $trigger -Settings $settings -Principal $principal -TaskName $taskname -Description $description *>$null
#startup
$action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-ExecutionPolicy Bypass -WindowStyle Hidden -Command `"iwr 'https://raw.githubusercontent.com/caglaryalcin/after-format/main/files/startup/Shells.psm1' -UseB | iex`""
$trigger = New-ScheduledTaskTrigger -AtStartup
$description = "You can check all the operations of this project at this link. https://github.com/caglaryalcin/after-format"
$principal = New-ScheduledTaskPrincipal -GroupId "S-1-5-32-544" -RunLevel Highest
$taskname = "startup"
$delay = "PT5M" # 5 minutes delay
$trigger.Delay = $delay
$settings = New-ScheduledTaskSettingsSet -Hidden:$true
$task = Register-ScheduledTask -TaskName $taskname -Trigger $trigger -Action $action -Principal $principal -Settings $settings -Description $description
$task.Triggers.Repetition.Duration = ""
$task.Triggers.Repetition.Interval = "PT3H"
$task | Set-ScheduledTask *>$null
Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black
}
elseif ($response -eq 'n' -or $response -eq 'N') {
Write-Host "[The start task will not be added to the task scheduler.]" -ForegroundColor Red -BackgroundColor Black
}
else {
Write-Host "Invalid input. Please enter 'y' for yes or 'n' for no."
ImportStartup
}
}
ImportStartup
Function DisableSnap {
Write-Host `n"Do you want to " -NoNewline
Write-Host "disable the Snap windows feature?" -ForegroundColor Yellow -NoNewline
Write-Host "(y/n): " -ForegroundColor Green -NoNewline
$response = Read-Host
if ($response -eq 'y' -or $response -eq 'Y') {
Write-Host "Disabling Snap windows feature..." -NoNewline
#Disable Snap
# Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name WindowArrangementActive -Value 0 *>$null
#Disable "When I snap a window, suggest what I can snap next to it"
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name SnapAssist -Value 0 *>$null
#Disable "Show snap layouts when I hover over a window's maximize button"
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name EnableSnapAssistFlyout -Value 0 *>$null
#Disable "Show snap layouts when I drag a window to the top of my screen"
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name EnableSnapBar -Value 0 *>$null
#Disable "Show my snapped windows when I hover taskbar apps, in Task View, and when I press Alt+Tab"
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name EnableTaskGroups -Value 0 *>$null
#Disable "When I drag a window, let me snap it without dragging all the way to the screen edge"
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name DITest -Value 0 *>$null
Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black
}
elseif ($response -eq 'n' -or $response -eq 'N') {
Write-Host "[Snap windows feature will not be disabled.]" -ForegroundColor Red -BackgroundColor Black
}
else {
Write-Host "[Invalid input. Please enter 'y' for yes or 'n' for no.]" -ForegroundColor Red -BackgroundColor Black
DisableSnap
}
}
DisableSnap
Function NVCleanUpdateTask {
Write-Host "`nDo you want to " -NoNewline
Write-Host "install NVCleanstall and import the update task?" -ForegroundColor Yellow -NoNewline
Write-Host "(y/n): " -ForegroundColor Green -NoNewline
$response = Read-Host
if ($response -eq 'y' -or $response -eq 'Y') {
Write-Host "Importing NVCleanstall Update task in Task Scheduler..." -NoNewline
$nvcleanstall = "https://drive.usercontent.google.com/download?id=1mLE9M8XckmwMD_7A6hkmuQ_j5Noz6pPr&export=download&confirm=t&uuid=3dafda5a-d638-4e45-8655-3e4dcc5a7212&at=APZUnTXgUibc057YzjK_mWRb_0Di%3A1713698912361"
$nvcleanpath = "C:\Program Files\NVCleanstall"
New-Item -ItemType Directory -Force -Path $nvcleanpath | Out-Null
Silent
Invoke-WebRequest -Uri $nvcleanstall -Outfile "$nvcleanpath\NVCleanstall_1.16.0.exe" -ErrorAction Stop
# Update task
$action = New-ScheduledTaskAction -Execute "$nvcleanpath\NVCleanstall_1.16.0.exe" -Argument "/check"
$description = "Check for new graphics card drivers"
$trigger1 = New-ScheduledTaskTrigger -AtLogon
$trigger2 = New-ScheduledTaskTrigger -Daily -At "10:00AM"
$principal = New-ScheduledTaskPrincipal -GroupId "S-1-5-32-544" -RunLevel Highest
$taskname = "NVCleanstall"
$settings = New-ScheduledTaskSettingsSet
$task = Register-ScheduledTask -TaskName $taskname -Trigger $trigger1, $trigger2 -Action $action -Principal $principal -Settings $settings -Description $description
# Remove repetition for trigger1
$task.Triggers[0].Repetition = $null
# Set repetition interval for trigger2
$task.Triggers[1].Repetition.Interval = "PT4H"
$task | Set-ScheduledTask *>$null
Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black
}
elseif ($response -eq 'n' -or $response -eq 'N') {
Write-Host "[NVCleanstall installation and update task import will not be performed.]" -ForegroundColor Red -BackgroundColor Black
}
else {
Write-Host "[Invalid input. Please enter 'y' for yes or 'n' for no.]" -ForegroundColor Red -BackgroundColor Black
NVCleanUpdateTask
}
}
NVCleanUpdateTask
Function TerminalConfig {
Write-Host "`nDo you want to " -NoNewline
Write-Host "configure Windows Terminal config?" -ForegroundColor Yellow -NoNewline
Write-Host "(y/n): " -ForegroundColor Green -NoNewline
$response = Read-Host
if ($response -eq 'y' -or $response -eq 'Y') {
Write-Host "Configuring Windows Terminal..." -NoNewline
$profileFolder = "$HOME\Documents\WindowsPowerShell"
if (-Not (Test-Path -Path $profileFolder)) {
New-Item -ItemType Directory -Path $profileFolder *>$null
}
$profileFile = "$profileFolder\Microsoft.PowerShell_profile.ps1"
$commands = @'
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\star.omp.json" | Invoke-Expression
clear
'@
Set-Content -Path $profileFile -Value $commands
Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black
}
elseif ($response -eq 'n' -or $response -eq 'N') {
Write-Host "[Windows Terminal config will not be set.]" -ForegroundColor Red -BackgroundColor Black
}
else {
Write-Host "[Invalid input. Please enter 'y' for yes or 'n' for no.]" -ForegroundColor Red -BackgroundColor Black
TerminalConfig
}
}
TerminalConfig
Function DisableGallery {
try {
Write-Host "Disabling gallery folder..." -NoNewline
New-Item -Path "HKCU:\Software\Classes\CLSID\{e88865ea-0e1c-4e20-9aa6-edcd0212c87c}" -ItemType Key *>$null
New-itemproperty -Path "HKCU:\Software\Classes\CLSID\{e88865ea-0e1c-4e20-9aa6-edcd0212c87c}" -Name "System.IsPinnedToNameSpaceTree" -Value "0" -PropertyType Dword *>$null
Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black
}
catch {
Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black
}
}
DisableGallery
Function ExplorerView {
# Set the separator setting in explorer
param (
[byte[]]$newColInfoValue = @(
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xFD, 0xDF, 0xDF, 0xFD, 0x10, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
0x30, 0xF1, 0x25, 0xB7, 0xEF, 0x47, 0x1A, 0x10,
0xA5, 0xF1, 0x02, 0x60, 0x8C, 0x9E, 0xEB, 0xAC,
0x0A, 0x00, 0x00, 0x00, 0x17, 0x01, 0x00, 0x00,
0x30, 0xF1, 0x25, 0xB7, 0xEF, 0x47, 0x1A, 0x10,
0xA5, 0xF1, 0x02, 0x60, 0x8C, 0x9E, 0xEB, 0xAC,
0x0E, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00,
0x30, 0xF1, 0x25, 0xB7, 0xEF, 0x47, 0x1A, 0x10,
0xA5, 0xF1, 0x02, 0x60, 0x8C, 0x9E, 0xEB, 0xAC,
0x04, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00,
0x30, 0xF1, 0x25, 0xB7, 0xEF, 0x47, 0x1A, 0x10,
0xA5, 0xF1, 0x02, 0x60, 0x8C, 0x9E, 0xEB, 0xAC,
0x0C, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00
)
)
Write-Host `n"Do you want to all folder views in explorer to be selected as " -NoNewline
Write-Host "details" -ForegroundColor Red -BackgroundColor Black -NoNewline
Write-Host " and set to separate?" -NoNewline
Write-Host "(y/n): " -ForegroundColor Green -NoNewline
$response = Read-Host
if ($response -eq 'y' -or $response -eq 'Y') {
Write-Host "Setting Explorer view settings to 'Details'..." -NoNewline
# Set the view settings to Details for all folders
$basePath = "HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags"
$bags = Get-ChildItem -Path $basePath -ErrorAction SilentlyContinue
foreach ($bag in $bags) {
# Exclude specific bags
if ($bag.PSChildName -in "1", "4", "24") {
continue
}
$shellPath = Join-Path $bag.PSPath "Shell"
if (Test-Path $shellPath) {
$subKeys = Get-ChildItem -Path $shellPath -Recurse -ErrorAction SilentlyContinue
foreach ($subKey in $subKeys) {
$subKeyPath = $subKey.PSPath
# Change the view settings
Set-ItemProperty -Path $subKeyPath -Name "Mode" -Value 4 -Type DWord -ErrorAction SilentlyContinue
Set-ItemProperty -Path $subKeyPath -Name "LogicalViewMode" -Value 1 -Type DWord -ErrorAction SilentlyContinue
Set-ItemProperty -Path $subKeyPath -Name "IconSize" -Value 10 -Type DWord -ErrorAction SilentlyContinue
Set-ItemProperty -Path $subKeyPath -Name "Vid" -Value "{137E7700-3573-11CF-AE69-08002B2E1262}" -Type String -ErrorAction SilentlyContinue
}
}
}
# Set the view separator settings to Details for all folders
Get-ChildItem -Path $basePath -Recurse -ErrorAction SilentlyContinue | ForEach-Object {
$subKeyPath = $_.PSPath
Get-ChildItem -Path $subKeyPath -Recurse -ErrorAction SilentlyContinue | ForEach-Object {
$colInfoPath = $_.PSPath
if (Test-Path -Path $colInfoPath -ErrorAction SilentlyContinue) {
$colInfo = Get-ItemProperty -Path $colInfoPath -Name "ColInfo" -ErrorAction SilentlyContinue
if ($colInfo) {
Set-ItemProperty -Path $colInfoPath -Name "ColInfo" -Value $newColInfoValue -ErrorAction SilentlyContinue
}
}
}
}
# Set control panel view
$Key1 = "HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\BagMRU"
$Data1 = "06 00 00 00 02 00 00 00 03 00 00 00 01 00 00 00 07 00 00 00 05 00 00 00 04 00 00 00 00 00 00 00 FF FF FF FF"
$byteArray1 = $Data1 -split ' ' | ForEach-Object { [byte]::Parse($_, [System.Globalization.NumberStyles]::HexNumber) }
Set-ItemProperty -Path $Key1 -Name "MRUListEx" -Value $byteArray1 -Type Binary -ErrorAction SilentlyContinue
$Key2 = "HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\24\Shell\{D674391B-52D9-4E07-834E-67C98610F39D}"
$Data2 = "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FD DF DF FD 10 00 00 00 00 00 00 00 00 00 00 00 05 00 00 00 18 00 00 00 30 F1 25 B7 EF 47 1A 10 A5 F1 02 60 8C 9E EB AC 0A 00 00 00 17 01 00 00 90 4F 1E 84 59 FF 16 4D 89 47 E8 1B BF FA B3 6D 02 00 00 00 C0 00 00 00 90 4F 1E 84 59 FF 16 4D 89 47 E8 1B BF FA B3 6D 0B 00 00 00 50 00 00 00 30 F1 25 B7 EF 47 1A 10 A5 F1 02 60 8C 9E EB AC 0C 00 00 00 50 00 00 00 53 7D EF 0C 64 FA D1 11 A2 03 00 00 F8 1F ED EE 08 00 00 00 80 00 00 00"
$byteArray2 = $Data2 -split ' ' | ForEach-Object { [byte]::Parse($_, [System.Globalization.NumberStyles]::HexNumber) }
Set-ItemProperty -Path $Key2 -Name "ColInfo" -Value $byteArray2 -Type Binary -ErrorAction SilentlyContinue
# Remove ShareX from context menu
reg delete "HKEY_CLASSES_ROOT\*\shell\ShareX" /f *> $null
# Restart Explorer
taskkill /f /im explorer.exe *> $null
Start-Process "explorer.exe" -NoNewWindow
Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black
}
elseif ($response -eq 'n' -or $response -eq 'N') {
Write-Host "[Explorer view will not be set to details.]" -ForegroundColor Red -BackgroundColor Black
}
else {
Write-Host "Invalid input. Please enter 'y' for yes or 'n' for no."
ExplorerView
}
}
ExplorerView
Function DisableSync {
Write-Host "Synchronization with Microsoft is completely disabling..." -NoNewline
$syncPath = "HKCU:\SOFTWARE\Policies\Microsoft\Windows\SettingSync"
$msaccountpath = "HKLM:\SOFTWARE\Microsoft\Windows\Currentversion\Policies\System"
$msaccountpath2 = "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\Settings\AllowYourAccount"
if (-not (Test-Path $syncPath)) {
New-Item -Path $syncPath -Force *>$null
}
try {
Set-ItemProperty -Path $syncPath -Name "DisableSettingSyncUserOverride" -Value 1
Set-ItemProperty -Path $syncPath -Name "DisableSyncYourSettings" -Value 1
Set-ItemProperty -Path $syncPath -Name "DisableWebBrowser" -Value 1
Set-ItemProperty -Path $syncPath -Name "DisablePersonalization" -Value 1
Set-ItemProperty -Path $syncPath -Name "DisableSettingSync" -Value 2
Set-ItemProperty -Path $msaccountpath -Name "NoConnectedUser" -Value 3
Set-ItemProperty -Path $msaccountpath2 -Name "value" -Value 0
Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black
}
catch {
Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black
}
}
DisableSync
function DisableSpotlight {
Write-Host "Disabling Spotlight..." -NoNewline
$RegistryKeys = @(
"HKCU:\SOFTWARE\Policies\Microsoft\Windows\CloudContent",
"HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"
)
foreach ($Key in $RegistryKeys) {
if (-not (Test-Path $Key)) {
New-Item -Path $Key -Force *>$null
}
}
try {
Set-ItemProperty -Path $RegistryKeys[0] -Name "NoWindowsSpotlight" -Value 1
Set-ItemProperty -Path $RegistryKeys[1] -Name "RotatingLockScreenOverlayEnabled" -Value 0
Set-ItemProperty -Path $RegistryKeys[1] -Name "SoftLandingEnabled" -Value 0
Set-ItemProperty -Path $RegistryKeys[1] -Name "RotatingLockScreenEnabled" -Value 0
Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black
}
catch {
Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black
}
}
DisableSpotlight
function DisableLockScreenNotifications {
Write-Host "Disabling lock screen notifications..." -NoNewline
$lockregistryPaths = @(
"HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings",
"HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications",
"HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications"
)
foreach ($path in $lockregistryPaths) {
if (-not (Test-Path $path)) {
New-Item -Path $path -Force *>$null
}
}
try {
Set-ItemProperty -Path $lockregistryPaths[0] -Name "NOC_GLOBAL_SETTING_ALLOW_TOASTS_ABOVE_LOCK" -Value 0
Set-ItemProperty -Path $lockregistryPaths[1] -Name "NoToastApplicationNotificationOnLockScreen" -Value 1
Set-ItemProperty -Path $lockregistryPaths[1] -Name "ToastEnabled" -Value 0
Set-ItemProperty -Path $lockregistryPaths[2] -Name "ToastEnabled" -Value 0
Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black
}
catch {
Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black
}
}
DisableLockScreenNotifications
Function DisableWMPDiagnostics {
Write-Host "Disabling Windows Media Player diagnostics..." -NoNewline
$WMPDiag1 = "HKCU:\Software\Microsoft\MediaPlayer\Preferences\HME"
if (-not (Test-Path $WMPDiag1)) {
New-Item -Path $WMPDiag1 -Force *>$null
}
$WMPDiag2 = "HKCU:\Software\Microsoft\MediaPlayer\Preferences"
if (-not (Test-Path $WMPDiag2)) {
New-Item -Path $WMPDiag2 -Force *>$null
}
try {
Set-ItemProperty -Path $WMPDiag1 -Name "WMPDiagnosticsEnabled" -Value 0
Set-ItemProperty -Path $WMPDiag2 -Name "UsageTracking" -Value 0
Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black
}
catch {
Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black
}
}
DisableWMPDiagnostics
Function DisableBingSearchExtension {
Write-Host "Disabling extension of Windows search with Bing..." -NoNewline
$bingsearch = "HKCU:\Software\Microsoft\Windows\CurrentVersion\SearchSettings"
if (-not (Test-Path $bingsearch)) {
New-Item -Path $bingsearch -Force *>$null
}
try {
Set-ItemProperty -Path $bingsearch -Name "DisableSearchBoxSuggestions" -Value 1
If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\SearchSettings")) {
New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\SearchSettings" -Force *>$null
}
New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS | Out-Null
$currentSID = [System.Security.Principal.WindowsIdentity]::GetCurrent().User.Value
Set-ItemProperty -Path "HKU:\$currentSID\Software\Microsoft\Windows\CurrentVersion\SearchSettings" -Name "IsDynamicSearchBoxEnabled" -Value 0
Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black
}
catch {
Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black
}
}
DisableBingSearchExtension
Function SetAppsMode {
Write-Host "`nDo you want to " -NoNewline
Write-Host "set the application mode to Light or Dark?" -ForegroundColor Yellow -NoNewline
Write-Host "(light/dark): " -ForegroundColor Green -NoNewline
$response = Read-Host
if ($response -eq 'light' -or $response -eq 'Light') {
Write-Host "Setting Light Mode for Applications..." -NoNewline
try {
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize" -Name "AppsUseLightTheme" -Type DWord -Value 1
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize" -Name "SystemUsesLightTheme" -Type DWord -Value 1
# Disable transparency
Set-ItemProperty -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize' -Name 'EnableTransparency' -Value 0
}
catch {
Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black
}
Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black
}
elseif ($response -eq 'dark' -or $response -eq 'Dark') {
Write-Host "Setting Dark Mode for Applications..." -NoNewline
try {
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize" -Name "AppsUseLightTheme" -Type DWord -Value 0
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize" -Name "SystemUsesLightTheme" -Type DWord -Value 0
# Disable transparency
Set-ItemProperty -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize' -Name 'EnableTransparency' -Value 0
}
catch {
Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black
}
Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black
}
else {
Write-Host "[Invalid input. Please enter 'light' for Light Mode or 'dark' for Dark Mode.]" -ForegroundColor Red -BackgroundColor Black
SetAppsMode
}
}
SetAppsMode
Function SetControlPanelLargeIcons {
Write-Host `n"Setting Control Panel view to large icons..." -NoNewline
try {
If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel")) {
New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel" -Force -ErrorAction Stop | Out-Null
}
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel" -Name "StartupPage" -Type DWord -Value 1 -ErrorAction Stop
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel" -Name "AllItemsIconView" -Type DWord -Value 0 -ErrorAction Stop
Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black
}
catch {
Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black
}
}
SetControlPanelLargeIcons
Function DisableDeviceEnumeration {
try {
# Disable devicemanager updates
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ShowDevMgrUpdates" -Value "0" -ErrorAction Stop
# Disable Windows sync notifications
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ShowSyncProviderNotifications" -Value "0" -ErrorAction Stop
# Disable Multimedia Device Enumeration
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "MMDevicesEnumerationEnabled" -Value 0 -ErrorAction Stop
# Disable device enumeration in File Explorer
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer" -Name "DisableDeviceEnumeration" -Value 1 -ErrorAction Stop
}
catch {
Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black
}
}
DisableDeviceEnumeration
Function EnableNumlock {
Write-Host "Enabling NumLock after startup..." -NoNewline
try {
If (!(Test-Path "HKU:")) {
New-PSDrive -Name "HKU" -PSProvider "Registry" -Root "HKEY_USERS" -ErrorAction Stop | Out-Null
}
# Enable NumLock after startup
Set-ItemProperty -Path "HKU:\.DEFAULT\Control Panel\Keyboard" -Name "InitialKeyboardIndicators" -Type DWord -Value "2147483650" -ErrorAction Stop
# Numlock control and settings
Add-Type -AssemblyName System.Windows.Forms -ErrorAction Stop
If (!([System.Windows.Forms.Control]::IsKeyLocked('NumLock'))) {
$wsh = New-Object -ComObject WScript.Shell
$wsh.SendKeys('{NUMLOCK}')
}
}
catch {
Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black
}
Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black
}
EnableNumlock
Function DisableBeepSound {
Write-Host "Disabling Windows Beep Sound..." -NoNewline
try {
Set-ItemProperty -Path "HKCU:\Control Panel\Sound" -Name "Beep" -Type String -Value no
Set-Service beep -StartupType disabled *>$null
}
catch {
Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black
}
Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black
}
DisableBeepSound
Function DisableIPv6 {
Write-Host "Disabling IPv6 stack..." -NoNewline
try {
Disable-NetAdapterBinding -Name "*" -ComponentID "ms_tcpip6"
}
catch {
Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black
}
Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black
}
DisableIPv6
Function SetDNS {
Function GetPingTime {
param (
[string]$address
)
$pingOutput = ping $address -n 2 | Select-String "time=" | Select-Object -Last 1
if ($pingOutput) {
$pingTime = [regex]::Match($pingOutput.ToString(), 'time=(\d+)ms').Groups[1].Value
return $pingTime
}
else {
return "N/A"
}
}
Write-Host `n"Would you like to change your " -NoNewline
Write-Host "DNS setting?" -ForegroundColor Yellow -NoNewline
Write-Host " (y/n): " -ForegroundColor Green -NoNewline
$confirmation = Read-Host
if ($confirmation -notin @("yes", "y", "Y")) {
Write-Host "DNS settings will not be changed."
return
}
Write-Host "Which DNS provider " -NoNewline
Write-Host "do you want to use?" -ForegroundColor Yellow -NoNewline
Write-Host " Write 1, 2 or 3."
Write-Host `n"MS values are being calculated..." -NoNewline
$cloudflareDNS = "1.1.1.1"
$googleDNS = "8.8.8.8"
$adguardDNS = "94.140.14.14"
$cloudflarePing = GetPingTime -address $cloudflareDNS
$googlePing = GetPingTime -address $googleDNS
$adguardPing = GetPingTime -address $adguardDNS
Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black
Write-Host `n"[1]" -NoNewline -BackgroundColor Black -ForegroundColor Yellow
Write-Host " - Cloudflare " -NoNewline
Write-Host "[$cloudflarePing" -ForegroundColor Yellow -BackgroundColor Black -NoNewline
Write-Host "ms]" -ForegroundColor Yellow -BackgroundColor Black
Write-Host "[2]" -NoNewline -BackgroundColor Black -ForegroundColor Yellow
Write-Host " - Google " -NoNewline
Write-Host "[$googlePing" -ForegroundColor Yellow -BackgroundColor Black -NoNewline
Write-Host "ms]" -ForegroundColor Yellow -BackgroundColor Black
Write-Host "[3]" -NoNewline -BackgroundColor Black -ForegroundColor Yellow
Write-Host " - Adguard " -NoNewline
Write-Host "[$adguardPing" -ForegroundColor Yellow -BackgroundColor Black -NoNewline
Write-Host "ms]" -ForegroundColor Yellow -BackgroundColor Black
$choice = Read-Host -Prompt `n"[Choice]"
$dnsServers = @()
switch ($choice) {
1 {
Write-Host `n"Setting Cloudflare DNS..." -NoNewline
$dnsServers = @("1.1.1.1", "1.0.0.1")
}
2 {
Write-Host `n"Setting Google DNS..." -NoNewline
$dnsServers = @("8.8.8.8", "8.8.4.4")
}
3 {
Write-Host `n"Setting Adguard DNS..." -NoNewline
$dnsServers = @("94.140.14.14", "94.140.15.15")
}
default {
Write-Host "Invalid input. Please enter 1, 2 or 3."
return
}
}
try {
$interfaces = Get-NetAdapter | Where-Object { $_.Status -eq "Up" } | Select-Object -ExpandProperty ifIndex
Set-DnsClientServerAddress -InterfaceIndex $interfaces -ServerAddresses $dnsServers -ErrorAction SilentlyContinue
}
catch {
Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black
}
Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black
}
SetDNS
Function ExplorerSettings {
Write-Host "Configuring Windows Explorer settings..." -NoNewline
$settings = @{
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer" = @{
"HudMode" = 1 # hide quick access
};
"HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" = @{
"LaunchTo" = 1; # 1 'This PC' #2 'Quick Access'
"HideFileExt" = 0; # Show known file extensions
"NavPaneExpandToCurrentFolder" = 0; # expand all folders
"NavPaneShowAllFolders" = 0 # show all folders
};
"HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer" = @{
"ShowFrequent" = 0; # Hide frequently used folders in quick access
"EnableAutoTray" = 0; # Show All Icons
"ShowCloudFilesInQuickAccess" = 0; # Hide cloud files in quick access
};
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" = @{
"HideSCAMeetNow" = 1 # HideSCAMeetNow
};
"HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" = @{
"HideSCAMeetNow" = 1 #Disable "meet now" in the taskbar
}
"HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\CabinetState" = @{
"FullPath" = 1; # Show full path in title bar
};
"HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\Search\Preferences" = @{
"ArchivedFiles" = 1 # Show archived files in search results
}