-
Notifications
You must be signed in to change notification settings - Fork 82
/
BlackViper-Win10.ps1
2589 lines (2411 loc) · 112 KB
/
BlackViper-Win10.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
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
##########
# Win 10 Black Viper Service Configuration Script
#
# Script + Menu(GUI) By
# Author: Madbomb122
# Website: https://GitHub.com/Madbomb122/BlackViperScript/
#
# Black Viper's Service Configurations By
# Author: Charles "Black Viper" Sparks
# Website: http://www.BlackViper.com/
#
$Script_Version = '6.2.3'
$Script_Date = 'Jun-22-2020'
$Release_Type = 'Stable'
##########
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# !! !!
# !! SAFE TO EDIT ITEM !!
# !! AT BOTTOM OF SCRIPT !!
# !! !!
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# !! !!
# !! CAUTION !!
# !! DO NOT EDIT PAST THIS POINT !!
# !! !!
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
<#------------------------------------------------------------------------------#>
$Copyright = ' Copyright (c) 2019 Zero Rights Reserved
- Services Configuration by Charles "Black Viper" Sparks
------------------------------------------------------------------------
The MIT License (MIT) + an added Condition
Copyright (c) 2017-2020 Madbomb122
- Black Viper Service Script
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice(s), this permission notice and ANY original
donation link shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
'
<#--------------------------------------------------------------------------------
.Prerequisite to run script
System*: Windows 10 x64 (64-bit)
Edition*: Home or Pro
Min Build*: Creator's Update
Max Build*: April 2018 Update
Files: This script and 'BlackViper.csv' (Service Configurations)
*Can run on x32/32-bit or other Edition, Build AT YOUR OWN RISK)
.DESCRIPTION
Script that can set services based on Black Viper's Service Configurations
or your own custom services, or backup services (created by this script)
.AT YOUR OWN RISK YOU CAN
1. Run the script on x86 (32-bit) w/o changing settings (But shows a warning)
2. Skip the check for
A. Home/Pro ($EditionCheck variable bottom of script or use -sec switch)
B. Creator's Update ($BuildCheck variable bottom of script or use -sbc switch)
.BASIC USAGE
1. Run script with (Next Line)
powershell.exe -NoProfile -ExecutionPolicy Bypass -File BlackViper-Win10.ps1
2. Use bat file provided
Use Gui to Select the desired Choices and click Run
.ADVANCED USAGE
One of the following Methods...
1. Edit values at bottom of the script then run script
2. Edit bat file and run
3. Run the script with one of these switches (space between multiple)
4. Run the script and pick options in GUI
Switch Description of Switch
-- Basic Switches --
-atos Accepts ToS
-auto Implies -atos...Runs the script to be Automated.. Closes on - User Input, Errors, or End of Script
--Service Configuration Switches--
-default Runs the script with Services to Default Configuration
-safe Runs the script with Services to Black Viper's Safe Configuration
-tweaked Runs the script with Services to Black Viper's Tweaked Configuration
-lcsc File.csv Loads Custom Service Configuration, File.csv = Name of your backup/custom file
--Service Choice Switches--
-all Every windows services will change
-min Just the services different from the default to safe/tweaked list
-sxb Skips changes to all XBox Services
--Update Switches--
-usc Checks for Update to Script file before running
-use Checks for Update to Service file before running
-sic Skips Internet Check, if you can't ping GitHub.com for some reason
--Log Switches--
-log Makes a log file using default name Script.log
-log File.log Makes a log file named File.log
-baf Log File of Services Configuration Before and After the script
--Backup Service Configuration--
-bscc Backup Current Service Configuration, Csv File
-bscr Backup Current Service Configuration, Reg File
-bscb Backup Current Service Configuration, Csv and Reg File
--Display Switches--
-sas Show Already Set Services
-snis Show Not Installed Services
-sss Show Skipped Services
--Misc Switches--
-dry Runs the Script and Shows what services will be changed
-css Change State of Service
-sds Stop Disabled Service
--AT YOUR OWN RISK Switches--
-secp Skips Edition Check by Setting Edition as Pro
-sech Skips Edition Check by Setting Edition as Home
-sbc Skips Build Check
--Dev Switches--
-devl Makes a log file with various Diagnostic information, Nothing is Changed
-diag Shows diagnostic information, Stops -auto
-diagf Forced diagnostic information, Script does nothing else
--Help--
-help Shows list of switches, then exits script.. alt -h
-copy Shows Copyright/License Information, then exits script
------------------------------------------------------------------------------#>
##########
# Pre-Script/Needed Variable -Start
##########
$WindowVersion = [Environment]::OSVersion.Version.Major
If($WindowVersion -ne 10) {
Write-Host 'Sorry, this Script supports Windows 10 ONLY.' -ForegroundColor 'cyan' -BackgroundColor 'black'
If($Automated -ne 1){ Read-Host -Prompt "`nPress Any key to Close..." } ;Exit
}
If($Release_Type -eq 'Stable'){ $ErrorActionPreference = 'SilentlyContinue' } Else{ $Release_Type = 'Testing' }
$PassedArg = $args
If(!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]'Administrator')) {
Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`" $PassedArg" -Verb RunAs ;Exit
}
$PCType = (Get-CimInstance Win32_ComputerSystem).PCSystemType
$CimOS = Get-CimInstance Win32_OperatingSystem | Select-Object OperatingSystemSKU,Caption,BuildNumber,OSArchitecture
$OSBit = $CimOS.OSArchitecture
$WinSku = $CimOS.OperatingSystemSKU
$WinSkuList = @(48,49,98,100,101)
# 48 = Pro, 49 = Pro N
# 98 = Home N, 100 = Home (Single Language), 101 = Home
$FullWinEdition = $CimOS.Caption
$WinEdition = $FullWinEdition.Split(' ')[-1]
# Pro or Home
# https://en.wikipedia.org/wiki/Windows_10_version_history
$BuildVer = $CimOS.BuildNumber
$Win10Ver = (Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name ReleaseID).ReleaseId
# 1909, November 2019 Update
# 1903, May 2019 Update
# 1809, October 2018 Update
$MaxVer,$MaxVerName = 1803, 'April 2018 Update'
# 1709, Fall Creators Update
$MinVer,$MinVerName = 1703, 'Creators Update'
# 1607, Anniversary Update
# 1511, November Update (First Major Update)
# 1507, First Release
$MySite = 'https://GitHub.com/madbomb122/BlackViperScript'
$URL_Base = $MySite.Replace('GitHub','raw.GitHub')+'/master/'
$Version_Url = $URL_Base + 'Version/Version.csv'
$Service_Url = $URL_Base + 'BlackViper.csv'
$Donate_Url = 'https://www.amazon.com/gp/registry/wishlist/YBAYWBJES5DE/'
$ServiceEnd = (Get-Service *_*).Where({$_.ServiceType -eq 224}, 'First') -Replace '^.+?_', '_'
$colors = @(
'black', #0
'blue', #1
'cyan', #2
'darkblue', #3
'darkcyan', #4
'darkgray', #5
'darkgreen', #6
'darkmagenta',#7
'darkred', #8
'darkyellow', #9
'gray', #10
'green', #11
'magenta', #12
'red', #13
'white', #14
'yellow') #15
$ColorsGUI = $Colors[14,15,7,3,4,5,6,2,8,9,10,11,12,13,0,1]
$ServicesTypeList = @(
'Skip', #0 -Skip/Not Installed
'Disabled',#1
'Manual', #2
'Auto', #3
'Auto') #4 -Auto (Delayed)
$ServicesTypeFull = $ServicesTypeList[0..4]
$ServicesTypeFull[4] = 'Auto (Delayed)'
$ServicesRegTypeList = @('','4','3','2','2') #Order is same as ServicesTypeFull
$SrvStateList = @('Running','Stopped')
$XboxServiceArr = @('XblAuthManager','XblGameSave','XboxNetApiSvc','XboxGipSvc','xbgm')
$NetTCP = @('NetMsmqActivator','NetPipeActivator','NetTcpActivator')
$FilterList = @('CheckboxChecked','CName','ServiceName','CurrType','BVType','SrvState','SrvDesc','SrvPath','RowColor')
$DevLogList = @('WPF_ScriptLog_CB','WPF_Diagnostic_CB','WPF_LogBeforeAfter_CB','WPF_DryRun_CB','WPF_ShowNonInstalled_CB','WPF_ShowAlreadySet_CB')
$FileBase = $(If($psISE -ne $Null){ Split-Path $psISE.CurrentFile.FullPath -Parent } Else{ $PSScriptRoot }) + '\'
$SettingPath = $FileBase + 'BVSetting.xml'
$ServiceFilePath = $FileBase + 'BlackViper.csv'
$BVServiceFilePath = $ServiceFilePath
$Black_Viper = 0
$Automated = 0
$All_or_Min = '-Min'
$ServiceMaker = 'BV-'
$RunScript = 2
$ErrorDi = ''
$LogStarted = 0
$LoadServiceConfig = 0
$RanScript = $False
$LaptopTweaked = 0
$ErrCount = $Error.Count
$GuiSwitch = $False
$ArgList = (0..28)
$ArgList[0] = @{ Arg = '-all' ;Var = 'All_or_Min=-Full';Match = 1 ;Gui = $True }
$ArgList[1] = @{ Arg = '-min' ;Var = 'All_or_Min=-Min' ;Match = 1 ;Gui = $True }
$ArgList[2] = @{ Arg = '-bscc' ;Var = @('BackupServiceConfig=1','BackupServiceType=1') ;Match = 2 ;Gui = $True }
$ArgList[3] = @{ Arg = '-bscr' ;Var = @('BackupServiceConfig=1','BackupServiceType=0') ;Match = 2 ;Gui = $True }
$ArgList[4] = @{ Arg = '-bscb' ;Var = @('BackupServiceConfig=1','BackupServiceType=2') ;Match = 2 ;Gui = $True }
$ArgList[5] = @{ Arg = '-baf' ;Var = 'LogBeforeAfter=1' ;Match = 1 ;Gui = $True }
$ArgList[6] = @{ Arg = '-snis' ;Var = 'ShowNonInstalled=1' ;Match = 1 ;Gui = $True }
$ArgList[7] = @{ Arg = '-sss' ;Var = 'ShowSkipped=1' ;Match = 1 ;Gui = $True }
$ArgList[8] = @{ Arg = '-sas' ;Var = 'ShowAlreadySet=1' ;Match = 1 ;Gui = $True }
$ArgList[9] = @{ Arg = '-sds' ;Var = 'StopDisabled=1' ;Match = 1 ;Gui = $True }
$ArgList[10] = @{ Arg = '-sic' ;Var = 'InternetCheck=1' ;Match = 1 ;Gui = $True }
$ArgList[11] = @{ Arg = '-css' ;Var = 'ChangeState=1' ;Match = 1 ;Gui = $True }
$ArgList[12] = @{ Arg = '-usc' ;Var = 'ScriptVerCheck=1' ;Match = 1 ;Gui = $True }
$ArgList[13] = @{ Arg = '-use' ;Var = 'ServiceVerCheck=1' ;Match = 1 ;Gui = $True }
$ArgList[14] = @{ Arg = '-atos' ;Var = 'AcceptToS=Accepted' ;Match = 1 ;Gui = $True }
$ArgList[15] = @{ Arg = '-dry' ;Var = 'DryRun=1' ;Match = 1 ;Gui = $True }
$ArgList[16] = @{ Arg = '-devl' ;Var = 'DevLog=1' ;Match = 1 ;Gui = $True }
$ArgList[17] = @{ Arg = '-sbc' ;Var = 'BuildCheck=1' ;Match = 1 ;Gui = $True }
$ArgList[18] = @{ Arg = '-sxb' ;Var = 'XboxService=1' ;Match = 1 ;Gui = $True }
$ArgList[19] = @{ Arg = '-sech' ;Var = 'EditionCheck=Home' ;Match = 1 ;Gui = $True }
$ArgList[20] = @{ Arg = '-secp' ;Var = 'EditionCheck=Pro' ;Match = 1 ;Gui = $True }
$ArgList[21] = @{ Arg = '-sec' ;Var = 'EditionCheck=Pro' ;Match = -1 ;Gui = $True }
$ArgList[22] = @{ Arg = '-default' ;Var = @('Black_Viper=1','BV_ArgUsed=2') ;Match = 1 ;Gui = $False }
$ArgList[23] = @{ Arg = '-safe' ;Var = @('Black_Viper=2','BV_ArgUsed=2') ;Match = 1 ;Gui = $False }
$ArgList[24] = @{ Arg = '-tweaked' ;Var = If($PCType -eq 1){ @('Black_Viper=3','BV_ArgUsed=2') } Else{ @('Black_Viper=0','BV_ArgUsed=1') } ;Match = 1 ;Gui = $False }
$ArgList[25] = @{ Arg = '-auto' ;Var = @('Automated=1','AcceptToS=Accepted') ;Match = 1 ;Gui = $False }
$ArgList[26] = @{ Arg = '-diag' ;Var = @('Diagnostic=1','Automated=0') ;Match = 2 ;Gui = $True }
$ArgList[27] = @{ Arg = '-log' ;Var = @('ScriptLog=1','LogName=-') ;Match = -1 ;Gui = $True }
$ArgList[28] = @{ Arg = '-logc' ;Var = @('ScriptLog=2','LogName=-') ;Match = -1 ;Gui = $True }
##########
# Pre-Script/Needed Variable -End
##########
# Multi Use Functions -Start
##########
Function AutomatedExitCheck([Int]$ExitBit) {
If($Automated -ne 1){ Read-Host -Prompt "`nPress Any key to Close..." }
If($ExitBit -eq 1){ LogEnd ;CloseExit }
}
Function LogEnd{ If(0 -NotIn $ScriptLog,$LogStarted){ Write-Output "--End of Log ($(Get-Date -Format 'MM/dd/yyyy hh:mm:ss tt'))--" | Out-File -LiteralPath $LogFile -Encoding Unicode -NoNewline -Append } }
Function GetTime{ Return Get-Date -Format 'hh:mm:ss tt' }
Function CloseExit{ If($GuiSwitch){ $Form.Close() } ;Exit }
Function GetCurrServices{ $Script:CurrServices = Get-CimInstance Win32_service | Select-Object DisplayName, Name, @{ Name = 'StartType' ;Expression = {$_.StartMode} }, @{ Name = 'Status' ;Expression = {$_.State} }, Description, PathName }
Function OpenWebsite([String]$Url){ Start $Url }
Function ShowInvalid([Bool]$InvalidA){ If($InvalidA){ Write-Host "`nInvalid Input" -ForegroundColor Red -BackgroundColor Black -NoNewline } Return $False }
Function DownloadFile([String]$Url,[String]$FilePath){ (New-Object System.Net.WebClient).DownloadFile($Url, $FilePath) }
Function QMarkServices([String]$Srv){ If($Srv -Match '_\?+$'){ Return ($Srv -Replace '_\?+$',$ServiceEnd) } Return $Srv }
Function SearchSrv([String]$Srv,[String]$Fil){ Return ($CurrServices.Where({$_.Name -eq $Srv}, 'First')).$Fil }
Function AutoDelayTest([String]$Srv){ $tmp = (Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\$Srv\").DelayedAutostart ;If($null -ne $tmp){ Return $tmp } Return 0 }
Function AutoDelaySet([String]$Srv,[Int]$EnDi){ Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Services\$Srv\" -Name 'DelayedAutostart' -Type DWord -Value $EnDi }
Function DisplayOut {
Param (
[Alias('T')] [String[]]$Text,
[Alias('C')] [Int[]]$Color,
[Alias('L')] [Switch]$Log,
[Alias('G')] [Switch]$Gui
)
If($Gui){ TBoxService @args }
For($i = 0 ;$i -lt $Text.Length ;$i++){ Write-Host $Text[$i] -ForegroundColor $colors[$Color[$i]] -BackgroundColor 'Black' -NoNewLine } ;Write-Host
If($Log -and $ScriptLog -eq 1){ Write-Output "$(GetTime): $($Text -Join ' ')" | Out-File -LiteralPath $LogFile -Encoding Unicode -Append }
}
Function DisplayOutLML {
Param ( [Alias('T')] [String]$Text, [Alias('C')] [Int[]]$Color, [Alias('L')] [Switch]$Log )
DisplayOut '| ',"$Text".PadRight(50),' |' -C 14,$Color,14 -L:$Log
}
Function DisplayMisc {
Param ( [Switch]$Menu, [Switch]$Line, [String]$Misc )
$txt = If($Line){ '|'.PadRight(53,'-') + '|' } Else{ '|'.PadRight(53) + '|' } #Line or Blank Spaces
$Splat = If($Menu) {
@{ Text = $txt ;Color = 14 ;Log = [bool]$Misc }
} Else { #For ToS
@{ Text = $txt ;Color = [int]$Misc ;Log = $False }
}
DisplayOut @Splat
}
Function Error_Top {
Clear-Host
DiagnosticCheck 0
DisplayMisc -Menu -Line -Misc $True
DisplayOutLML (''.PadRight(22)+'Error') -C 13 -L
DisplayMisc -Menu -Line -Misc $True
DisplayMisc -Menu -Misc $True
}
Function Error_Bottom {
DisplayMisc -Misc $True
DisplayMisc -Line -Misc $True
If($Diagnostic -eq 1){ DiagnosticCheck 0 }
AutomatedExitCheck 1
}
##########
# Multi Use Functions -End
##########
# TOS -Start
##########
Function ShowCopyright { Clear-Host ;DisplayOut $Copyright -C 14 }
Function TOSDisplay([Switch]$C) {
If(!$C){ Clear-Host }
$BC = 14
If($Release_Type -ne 'Stable') {
$BC = 15
DisplayMisc -Line -Misc 15
DisplayOut '|'.PadRight(22),'Caution!!!'.PadRight(31),'|' -C 15,13,15
DisplayMisc -Misc 15
DisplayOut '|',' This script is still being tested. ','|' -C 15,14,15
DisplayOut '|'.PadRight(17),'USE AT YOUR OWN RISK.'.PadRight(36),'|' -C 15,14,15
DisplayMisc -Misc 15
}
If($OSBit -ne '64-bit') {
$BC = 15
DisplayMisc -Line -Misc 15
DisplayOut '|'.PadRight(22),'WARNING!!!'.PadRight(31),'|' -C 15,13,15
DisplayMisc -Misc 15
DisplayOut '|',' These settings are meant for x64 Bit. ','|' -C 15,14,15
DisplayOut '|'.PadRight(17),'USE AT YOUR OWN RISK.'.PadRight(36),'|' -C 15,14,15
DisplayMisc -Misc 15
}
DisplayMisc -Line -Misc $BC
DisplayOut '|'.PadRight(21),'Terms of Use'.PadRight(32),'|' -C $BC,11,$BC
DisplayMisc -Line -Misc $BC
DisplayMisc -Misc $BC
DisplayOut '|',' This program comes with ABSOLUTELY NO WARRANTY. ','|' -C $BC,2,$BC
DisplayOut '|',' This is free software, and you are welcome to ','|' -C $BC,2,$BC
DisplayOut '|',' redistribute it under certain conditions. ','|' -C $BC,2,$BC
DisplayMisc -Misc $BC
DisplayOut '|',' Read License file for full Terms.'.PadRight(52),'|' -C $BC,2,$BC
DisplayMisc -Misc $BC
DisplayOut '|',' Use the switch ','-copy',' to see License Information or ','|' -C $BC,2,14,2,$BC
DisplayOut '|',' enter ','L',' bellow.'.PadRight(44),'|' -C $BC,2,14,2,$BC
DisplayMisc -Misc $BC
DisplayMisc -Line -Misc $BC
}
Function TOS {
$Invalid = $False
$CR = $False
While($TOS -ne 'Out') {
TOSDisplay -C:$CR
$CR = $False
$Invalid = ShowInvalid $Invalid
$TOS = Read-Host "`nDo you Accept? (Y)es/(N)o"
If($TOS -In 'n','no') {
Exit
} ElseIf($TOS -In 'y','yes') {
$TOS = 'Out'
$Script:AcceptToS = 'Accepted'
$Script:RunScript = 1
If($LoadServiceConfig -eq 1){ Black_Viper_Set } ElseIf($Black_Viper -eq 0){ GuiStart } Else{ Black_Viper_Set $Black_Viper $All_or_Min }
} ElseIf($TOS -eq 'l') {
$CR = $True ;ShowCopyright
} Else {
$Invalid = $True
}
} Return
}
##########
# TOS -End
##########
# GUI -Start
##########
Function OpenSaveDiaglog([Int]$SorO) {
$SOFileDialog = If($SorO -eq 0){ New-Object System.Windows.Forms.OpenFileDialog } Else{ New-Object System.Windows.Forms.SaveFileDialog }
$SOFileDialog.InitialDirectory = $FileBase
$SOFileDialog.Filter = If($SorO -ne 2){ 'CSV (*.csv)| *.csv' } Else{ 'Registration File (*.reg)| *.reg' }
$SOFileDialog.ShowDialog()
$SOFPath = $SOFileDialog.Filename
If($SOFPath) {
If($SorO -eq 0) {
$Script:ServiceConfigFile = $SOFPath ;$WPF_LoadFileTxtBox.Text = $ServiceConfigFile ;RunDisableCheck
} ElseIf($SorO -eq 1) {
Save_Service $SOFPath
} ElseIf($SorO -eq 2) {
RegistryServiceFile $SOFPath
}
}
}
Function HideShowCustomSrvStuff {
$Vis,$TF,$WPF_CustomNoteGrid.Visibility = If(($WPF_ServiceConfig.SelectedIndex+1) -eq $BVCount){ 'Visible',$False,'Visible' } Else{ 'Hidden',$True,'Collapsed' }
$WPF_RadioAll, $WPF_RadioMin | Where { $_.IsEnabled = $TF }
$WPF_CustomNote, $WPF_LoadFileTxtBox, $WPF_btnOpenFile | Where { $_.Visibility = $Vis }
}
Function SetServiceVersion {
If(Test-Path -LiteralPath $BVServiceFilePath -PathType Leaf) {
$TMP = Import-Csv -LiteralPath $BVServiceFilePath
$Script:ServiceVersion = $TMP[0].'BV-Def-Home'
$Script:ServiceDate = $TMP[0].'BV-Def-Pro'
Return $True
}
$Script:ServiceVersion = 'Missing File'
$Script:ServiceDate = 'BlackViper.csv'
Return $False
}
Function ClickedDonate{ OpenWebsite $Donate_Url ;$Script:ConsideredDonation = 'Yes' }
Function UpdateSetting {
$VarList.ForEach{
$SetValue = If($_.Value.IsChecked){ 1 } Else{ 0 }
Set-Variable -Name ($_.Name.Split('_')[1]) -Value $SetValue -Scope Script
}
$Script:All_or_Min = If($WPF_RadioAll.IsChecked){ '-Full' } Else{ '-Min' }
UpdateEdition
$Script:LogName = $WPF_LogNameInput.Text
$Script:BackupServiceType = $WPF_BackupServiceType.SelectedIndex
}
Function SaveSetting {
UpdateSetting
$Black_Viper = $WPF_ServiceConfig.SelectedIndex
If(($Black_Viper+1) -eq $BVCount -or ($IsLaptop -eq '-Lap' -and $LaptopTweaked -ne 1 -and $Black_Viper -ge 2)){ $Black_Viper = 0 }
$Settings = @{
AcceptToS = $AcceptToS
EditionCheck = $EditionCheck
BuildCheck = $BuildCheck
LaptopTweaked = $LaptopTweaked
Black_Viper = $Black_Viper
All_or_Min = $All_or_Min
BackupServiceConfig = $BackupServiceConfig
BackupServiceType = $BackupServiceType
InternetCheck = $InternetCheck
ScriptVerCheck = $ScriptVerCheck
ServiceVerCheck = $ServiceVerCheck
ShowConsole = $ShowConsole
XboxService = $XboxService
StopDisabled = $StopDisabled
ChangeState = $ChangeState
ShowSkipped = $ShowSkipped
}
If($ConsideredDonation -eq 'Yes'){ $Settings.ConsideredDonation = 'Yes' }
If($WPF_DevLogCB.IsChecked) {
$Settings | ForEach-Object{
$_.ScriptLog = $Script_Log
$_.LogName = $Log_Name
$_.Diagnostic = $Diagn_ostic
$_.LogBeforeAfter = $Log_Before_After
$_.DryRun = $Dry_Run
$_.ShowNonInstalled = $Show_Non_Installed
$_.ShowAlreadySet = $Show_Already_Set
}
} Else {
$Settings | ForEach-Object{
$_.ScriptLog = $ScriptLog
$_.LogName = $LogName
$_.Diagnostic = $Diagnostic
$_.LogBeforeAfter = $LogBeforeAfter
$_.DryRun = $DryRun
$_.ShowNonInstalled = $ShowNonInstalled
$_.ShowAlreadySet = $ShowAlreadySet
}
}
If(Test-Path -LiteralPath $SettingPath -PathType Leaf) {
$Tmp = (Import-Clixml -LiteralPath $SettingPath | ConvertTo-Xml).Objects.Object.Property."#text"
If(($Tmp.Count/2) -eq $Settings.Count) {
$T1 = While($Tmp){ $Key, $Val, $Tmp = $Tmp ;[PSCustomObject] @{ Name = $Key ;Val = $Val } }
$Tmp = ($Settings | ConvertTo-Xml).Objects.Object.Property."#text"
$T2 = While($Tmp){ $Key, $Val, $Tmp = $Tmp ;[PSCustomObject] @{ Name = $Key ;Val = $Val } }
If(Compare-Object $T1 $T2 -Property Name,Val){ $SaveSettingFile = $True }
} Else {
$SaveSettingFile = $True
}
} Else {
$SaveSettingFile = $True
}
If($SaveSettingFile){ $Settings | Export-Clixml -LiteralPath $SettingPath }
}
Function ShowConsoleWin([Int]$Choice){ [Console.Window]::ShowWindow($ConsolePtr, $Choice) }#0 = Hide, 5 = Show
Function GuiStart {
#Needed to Hide Console window
Add-Type -Name Window -Namespace Console -MemberDefinition '[DllImport("Kernel32.dll")] public static extern IntPtr GetConsoleWindow() ;[DllImport("user32.dll")] public static extern bool ShowWindow(IntPtr hWnd, Int32 nCmdShow);'
$Script:ConsolePtr = [Console.Window]::GetConsoleWindow()
Clear-Host
DisplayOut 'Preparing GUI, Please wait...' -C 15
$Script:GuiSwitch = $True
[xml]$XAML =@"
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Black Viper Service Configuration Script By: MadBomb122" Height="540" Width="720" BorderBrush="Black" Background="White">
<Window.Resources>
<Style x:Key="SeparatorStyle1" TargetType="{x:Type Separator}">
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="Margin" Value="0,0,0,0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Separator}">
<Border Height="24" SnapsToDevicePixels="True" Background="#FF4D4D4D" BorderBrush="#FF4D4D4D" BorderThickness="0,0,0,1"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type ToolTip}"><Setter Property="Background" Value="#FFFFFFBF"/></Style>
</Window.Resources>
<Window.Effect><DropShadowEffect/></Window.Effect>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="24"/>
<RowDefinition Height="*"/>
<RowDefinition Height="48"/>
</Grid.RowDefinitions>
<Menu Grid.Row="0" IsMainMenu="True">
<MenuItem Header="Help">
<MenuItem Name="FeedbackButton" Header="Feedback/Bug Report"/>
<MenuItem Name="FAQButton" Header="FAQ"/>
<MenuItem Name="AboutButton" Header="About"/>
<MenuItem Name="CopyrightButton" Header="Copyright"/>
<MenuItem Name="ContactButton" Header="Contact Me"/>
</MenuItem>
<MenuItem Name="DonateButton" Header="Donate to Me" Background="Orange" FontWeight="Bold"/>
<MenuItem Name="Madbomb122WSButton" Header="Madbomb122's GitHub" Background="Gold" FontWeight="Bold"/>
<MenuItem Name="BlackViperWSButton" Header="BlackViper's Website" Background="ForestGreen" FontWeight="Bold"/>
</Menu>
<Grid Grid.Row="1">
<TabControl BorderBrush="Gainsboro" Grid.Row="1" Name="TabControl">
<TabControl.Resources>
<Style TargetType="TabItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TabItem">
<Border Name="Border" BorderThickness="1,1,1,0" BorderBrush="Gainsboro" CornerRadius="4,4,0,0" Margin="2,0">
<ContentPresenter x:Name="ContentSite" VerticalAlignment="Center" HorizontalAlignment="Center" ContentSource="Header" Margin="10,2"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="Border" Property="Background" Value="LightSkyBlue" />
</Trigger>
<Trigger Property="IsSelected" Value="False">
<Setter TargetName="Border" Property="Background" Value="GhostWhite" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</TabControl.Resources>
<TabItem Name="Services_Tab" Header="Services Options">
<Grid Background="#FFE5E5E5">
<Grid.RowDefinitions>
<RowDefinition Height="1.5*"/>
<RowDefinition Height="0.5*"/>
</Grid.RowDefinitions>
<GroupBox Grid.Row="0" FontWeight="Bold" Header="Service Configuration" Grid.RowSpan="2">
<Grid Grid.Row="0" Margin="5">
<Grid.RowDefinitions>
<RowDefinition Height="47*"/>
<RowDefinition Height="33*"/>
<RowDefinition Height="33*"/>
<RowDefinition Height="82*"/>
<RowDefinition Height="80*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="3.5*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<RadioButton Grid.Row="1" Grid.Column="1" Name="RadioAll" HorizontalAlignment="Left" VerticalAlignment="Center" IsChecked="True" Content="All -Change All Services" Margin="5"/>
<RadioButton Grid.Row="2" Grid.Column="1" Name="RadioMin" HorizontalAlignment="Left" VerticalAlignment="Center" Content="Min -Change Services that are Different from Default to Safe/Tweaked" Margin="5"/>
<Grid Grid.Row="3" Grid.Column="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="145*"/>
<ColumnDefinition Width="127*"/>
<ColumnDefinition Width="165*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" FontWeight="Bold" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5">Service Configurations:</TextBlock>
<ComboBox Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center" Name="ServiceConfig" Margin="5">
<ComboBoxItem Content="Default" IsSelected="True"/>
<ComboBoxItem Content="Safe"/>
<ComboBoxItem Content="Tweaked"/>
<ComboBoxItem Content="Custom Setting *"/>
</ComboBox>
<TextBlock Name="CustomNote" Grid.Column="2" FontWeight="Bold" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5">Configure Below</TextBlock>
</Grid>
</Grid>
</GroupBox>
<GroupBox Name="CustomNoteGrid" FontWeight="Bold" Header="Custom Configuration" Grid.Row="1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="4*"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Name="btnOpenFile" Margin="5" Content="Browse"/>
<TextBlock Grid.Column="1" Name="LoadFileTxtBox"/>
</Grid>
</GroupBox>
</Grid>
</TabItem>
<TabItem Name="ServicesDG_Tab" Header="Services List">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="75"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="4*"/>
<ColumnDefinition Width="9.4*"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Grid.Row="0" Name="LoadServicesButton" Content="Reload Services" VerticalAlignment="Center"/>
<Button Grid.Column="1" Grid.Row="0" Name="SaveCustomSrvButton" Content="Save Current" VerticalAlignment="Center"/>
<Button Grid.Column="2" Grid.Row="0" Name="SaveRegButton" Content="Save Registry" VerticalAlignment="Center" />
<CheckBox Grid.Column="3" Grid.Row="0" Name="CustomBVCB" Content="Customize Service" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBlock Grid.Column="4" Grid.RowSpan="2" Name="TableLegend" FontWeight="Bold" TextAlignment="Left" Margin="2">
<Run Background="LightGreen" Text="Service is within selected configuration compliance"/><LineBreak/>
<Run Background="LightCoral" Text="Service is NOT in selected configuration compliance"/><LineBreak/>
<Run Background="Yellow" Text="Service is not covered in the selected configuration"/><LineBreak/>
<Run Text="You may uncheck services you don't want changed"/></TextBlock>
<TextBox Grid.Column="0" Grid.ColumnSpan="3" Grid.Row="1" Name="FilterTxt" TextWrapping="Wrap" Margin="8"/>
<ComboBox Grid.Column="3" Grid.Row="1" Name="FilterType" VerticalAlignment="Top" Margin="8">
<ComboBoxItem Content="Checked"/>
<ComboBoxItem Content="Common Name" IsSelected="True"/>
<ComboBoxItem Content="Service Name"/>
<ComboBoxItem Content="Current Setting"/>
</ComboBox>
</Grid>
<DataGrid Grid.Row="1" Name="dataGrid" FrozenColumnCount="2" AutoGenerateColumns="False" AlternationCount="2" HeadersVisibility="Column" CanUserResizeRows="False" CanUserAddRows="False" IsTabStop="True" IsTextSearchEnabled="True" SelectionMode="Extended">
<DataGrid.RowStyle>
<Style TargetType="{ x:Type DataGridRow }">
<Style.Triggers>
<Trigger Property="AlternationIndex" Value="0">
<Setter Property="Background" Value="White"/>
</Trigger>
<Trigger Property="AlternationIndex" Value="1">
<Setter Property="Background" Value="#FFD8D8D8"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="ToolTip">
<Setter.Value>
<TextBlock Text="{ Binding SrvDesc }" TextWrapping="Wrap" Width="400" Background="#FFFFFFBF" Foreground="Black"/>
</Setter.Value>
</Setter>
<Setter Property="ToolTipService.ShowDuration" Value="360000000"/>
</Trigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{ Binding checkboxChecked }" Value="True"/>
<Condition Binding="{ Binding Matches }" Value="False"/>
</MultiDataTrigger.Conditions>
<Setter Property="Background" Value="#F08080"/>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{ Binding checkboxChecked }" Value="False"/>
<Condition Binding="{ Binding Matches }" Value="False"/>
</MultiDataTrigger.Conditions>
<Setter Property="Background" Value="#FFFFFF64"/>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{ Binding checkboxChecked }" Value="True"/>
<Condition Binding="{ Binding Matches }" Value="True"/>
</MultiDataTrigger.Conditions>
<Setter Property="Background" Value="LightGreen"/>
</MultiDataTrigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
<DataGrid.Columns>
<DataGridTemplateColumn SortMemberPath="checkboxChecked" CanUserSort="True">
<DataGridTemplateColumn.Header>
<CheckBox Name="ACUcheckboxChecked" IsEnabled="False"/>
</DataGridTemplateColumn.Header>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding checkboxChecked,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged,NotifyOnTargetUpdated=True}" IsEnabled="{Binding ElementName=CustomBVCB, Path=IsChecked}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Header="Common Name" Width="121" Binding="{Binding CName}" CanUserSort="True" IsReadOnly="True"/>
<DataGridTextColumn Header="Service Name" Width="120" Binding="{Binding ServiceName}" IsReadOnly="True"/>
<DataGridTextColumn Header="Current Setting" Width="95" Binding="{Binding CurrType}" IsReadOnly="True"/>
<DataGridTemplateColumn Header="Black Viper" Width="105" SortMemberPath="BVType" CanUserSort="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox ItemsSource="{Binding ServiceTypeListDG}" Text="{Binding Path=BVType, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsEnabled="{Binding ElementName=CustomBVCB, Path=IsChecked}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="State" Width="80" SortMemberPath="SrvState" CanUserSort="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox ItemsSource="{Binding SrvStateListDG}" Text="{Binding Path=SrvState, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsEnabled="{Binding ElementName=CustomBVCB, Path=IsChecked}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Header="Description" Width="120" Binding="{Binding SrvDesc}" CanUserSort="True" IsReadOnly="True"/>
<DataGridTextColumn Header="Path" Width="120" Binding="{Binding SrvPath}" CanUserSort="True" IsReadOnly="True"/>
</DataGrid.Columns>
</DataGrid>
</Grid>
</TabItem>
<TabItem Name="Options_tab" Header="Script Options">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<Grid.RowDefinitions>
<RowDefinition Height="3*"/>
<RowDefinition Height="4*"/>
<RowDefinition Height="4*"/>
</Grid.RowDefinitions>
<GroupBox Grid.Row="0" Content="Display Options" FontWeight="Bold" Margin="5"/>
<Grid Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="10"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<CheckBox Grid.Row="1" Grid.Column="1" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Center" Name="ShowAlreadySet_CB" Content="Show Already Set Services" IsChecked="True"/>
<CheckBox Grid.Row="2" Grid.Column="1" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Center" Name="ShowNonInstalled_CB" Content="Show Not Installed Services"/>
<CheckBox Grid.Row="3" Grid.Column="1" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Center" Name="ShowSkipped_CB" Content="Show Skipped Services"/>
</Grid>
<GroupBox Grid.Row="1" Content="Miscellaneous" FontWeight="Bold" Margin="5"/>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="10"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<CheckBox Grid.Row="1" Grid.Column="1" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Center" Name="Dryrun_CB" Content="Dryrun / What if"/>
<CheckBox Grid.Row="2" Grid.Column="1" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Center" Name="XboxService_CB" Content="Skip All Xbox Services"/>
<CheckBox Grid.Row="3" Grid.Column="1" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Center" Name="ChangeState_CB" Content="Allow Change of Service State"/>
<CheckBox Grid.Row="4" Grid.Column="1" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Center" Name="StopDisabled_CB" Content="Stop Disabled Services"/>
</Grid>
<GroupBox Grid.Row="2" Content="Development" FontWeight="Bold" Margin="5"/>
<Grid Grid.Row="2">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="10"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="10"/>
</Grid.ColumnDefinitions>
<CheckBox Grid.Row="1" Grid.Column="1" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Center" Name="Diagnostic_CB" Content="Diagnostic Output (On Error)"/>
<CheckBox Grid.Row="2" Grid.Column="1" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Center" Name="DevLogCB" Content="Enable Development Logging"/>
<CheckBox Grid.Row="3" Grid.Column="1" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Center" Name="ShowConsole_CB" Content="Show Console Window"/>
<Button Grid.Row="4" Grid.Column="1" Margin="5" Content="Show Diagnostic" Name="ShowDiagButton"/>
</Grid>
</Grid>
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="2*"/>
</Grid.RowDefinitions>
<GroupBox Grid.Row="0" Content="Build Checks" FontWeight="Bold" Margin="5"/>
<Grid Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="2*"/>
<RowDefinition Height="2*"/>
<RowDefinition Height="2*"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="10*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="1" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Center" FontWeight="Bold" Grid.Column="2">Enabling these carries some risk</TextBlock>
<CheckBox Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Center" Name="BuildCheck_CB" Content="Skip Build/Version Check"/>
<CheckBox Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="2" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Center" Name="EditionCheckCB" AutomationProperties.HelpText="Override Edition Check"/>
<ComboBox Grid.Row="3" Grid.Column="2" Margin="5" HorizontalAlignment="Left" Name="EditionConfig">
<ComboBoxItem Content="Override Edition Check" IsSelected="True"/>
<ComboBoxItem Content="Home"/>
<ComboBoxItem Content="Pro"/>
</ComboBox>
</Grid>
<GroupBox Grid.Row="1" Content="Logging" FontWeight="Bold" Margin="5"/>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="3*"/>
<RowDefinition Height="3*"/>
<RowDefinition Height="3*"/>
<RowDefinition Height="3*"/>
<RowDefinition Height="3*"/>
<RowDefinition Height="3*"/>
<RowDefinition Height="8*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="10*"/>
</Grid.ColumnDefinitions>
<CheckBox Grid.Row="1" Grid.Column="1" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Center" Name="LogBeforeAfter_CB" Content="Log Services Before & After" Grid.ColumnSpan="2"/>
<CheckBox Grid.Row="2" Grid.Column="1" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Center" Name="ScriptLog_CB" Content="Script Log" Grid.ColumnSpan="2"/>
<TextBox Grid.Row="3" Grid.Column="2" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Center" Name="LogNameInput" TextAlignment="Left" Text="$FullPath\Script.log" Grid.ColumnSpan="2" MinWidth="100"/>
<CheckBox Grid.Row="4" Grid.Column="1" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Center" Name="BackupServiceConfig_CB" Content="Backup Current Service" Grid.ColumnSpan="2"/>
<ComboBox Grid.Row="5" Grid.Column="2" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Center" Name="BackupServiceType">
<ComboBoxItem Content=".reg" HorizontalAlignment="Left"/>
<ComboBoxItem Content=".csv" HorizontalAlignment="Left" IsSelected="True"/>
<ComboBoxItem Content="Both" HorizontalAlignment="Left"/>
</ComboBox>
</Grid>
</Grid>
<Grid Grid.Column="2">
<Grid.RowDefinitions>
<RowDefinition Height="106*"/>
<RowDefinition Height="31*"/>
</Grid.RowDefinitions>
<GroupBox Grid.Row="0" Content="Update Items" FontWeight="Bold" Margin="5"/>
<Grid Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="2*"/>
<RowDefinition Height="3*"/>
<RowDefinition Height="3*"/>
<RowDefinition Height="3*"/>
<RowDefinition Height="2*"/>
<RowDefinition Height="2*"/>
<RowDefinition Height="2*"/>
<RowDefinition Height="5*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="10"/>
</Grid.ColumnDefinitions>
<Button Grid.Row="1" Grid.Column="1" Margin="5" Name="UpdateServiceButton" Content="Check Service Configuration"/>
<Button Grid.Row="2" Grid.Column="1" Margin="5" Name="UpdateScriptButton" Content="Check Service Utility Script"/>
<Button Grid.Row="3" Grid.Column="1" Margin="5" Name="UpdateBothButton" Content="Check Update Both"/>
<CheckBox Grid.Row="4" Grid.Column="1" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Center" Name="ServiceVerCheck_CB" Content="Auto Service Update"/>
<CheckBox Grid.Row="5" Grid.Column="1" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Center" Name="ScriptVerCheck_CB" Content="Auto Script Update"/>
<CheckBox Grid.Row="6" Grid.Column="1" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Center" Name="InternetCheck_CB" Content="Skip Internet Check"/>
<TextBlock Grid.Row="7" Grid.Column="1" Margin="5" HorizontalAlignment="Center" VerticalAlignment="Top" TextWrapping="Wrap" TextAlignment="Center" FontWeight="Bold">
<Run Text="Will run and use current settings whether disabled or enabled...."/>
</TextBlock>
</Grid>
<GroupBox Name="LaptopTweakBox" Grid.Row="1" Content="Various" FontWeight="Bold" Margin="5"/>
<Grid Name="LaptopTweakGrid" Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="2*"/>
<RowDefinition Height="2*"/>
<RowDefinition Height="2*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<CheckBox Grid.Row="1" Grid.Column="1" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Center" Name="LaptopTweaked_CB" Content="*** Enable Laptop Tweaks ***"/>
<TextBlock Grid.Row="2" Grid.RowSpan="2" Grid.ColumnSpan="2" Margin="5" HorizontalAlignment="Center" VerticalAlignment="Top" TextWrapping="Wrap" TextAlignment="Center" FontWeight="Bold" Text="***Not Recommended***"/>
</Grid>
</Grid>
</Grid>
</TabItem>
<TabItem Name="ServiceChanges" Header="Service Changes">
<ScrollViewer VerticalScrollBarVisibility="Visible">
<TextBlock Name="ServiceListing" TextTrimming="CharacterEllipsis" Background="White"/>
</ScrollViewer>
</TabItem>
<TabItem Name="DiagnosticTab" Header="Diagnostic" Visibility="Hidden">
<ScrollViewer VerticalScrollBarVisibility="Visible">
<TextBlock Name="DiagnosticOutput" TextTrimming="CharacterEllipsis" Background="White"/>
</ScrollViewer>
</TabItem>
</TabControl>
</Grid>
<Grid Grid.Row="2">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Grid.Row="0" Grid.ColumnSpan="2" Name="RunScriptButton" Content="Run Script" FontWeight="Bold"/>
<TextBox Grid.Row="1" Grid.Column="0" Name="Script_Ver_Txt" TextAlignment="Center">Script Version: $Script_Version ($Script_Date) [$Release_Type]</TextBox>
<TextBox Grid.Row="1" Grid.Column="1" Name="Service_Ver_Txt" TextAlignment="Center"/>
</Grid>
</Grid>
</Window>
"@
[Void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework')
$Form = [Windows.Markup.XamlReader]::Load( (New-Object System.Xml.XmlNodeReader $xaml) )
$xaml.SelectNodes('//*[@Name]').ForEach{Set-Variable -Name "WPF_$($_.Name)" -Value $Form.FindName($_.Name) -Scope Script}
$Runspace = [RunSpaceFactory]::CreateRunspace()
$PowerShell = [PowerShell]::Create()
$PowerShell.RunSpace = $Runspace
$Runspace.Open()
[System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms') | Out-Null
[System.Collections.ArrayList]$Script:VarList = Get-Variable 'WPF_*_CB'
$Script:DataGridListBlank = @{}
$Form.add_closing{
If(!$RanScript -And [Windows.Forms.Messagebox]::Show('Are you sure you want to exit?','Exit','YesNo') -eq 'No'){ $_.Cancel = $True }
SaveSetting
LogEnd
ShowConsoleWin 5
}
$WPF_RunScriptButton.Add_Click{
If($EBFailCount -eq 0) {
RunScriptFun
} ElseIf($EBFailCount -eq 1) {