forked from madbomb122/BlackViperScript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBlackViper-Win10.ps1
1519 lines (1384 loc) · 77.9 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 = "4.1"
$Minor_Version = "3"
$Script_Date = "Feb-08-2018"
$Release_Type = "Stable"
##########
## !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
## !! !!
## !! SAFE TO EDIT ITEM !!
## !! AT BOTTOM OF SCRIPT !!
## !! !!
## !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
## !! !!
## !! CAUTION !!
## !! DO NOT EDIT PAST THIS POINT !!
## !! !!
## !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
<#------------------------------------------------------------------------------
Copyright (c) 1999-2017 Charles "Black Viper" Sparks - Services Configuration
The MIT License (MIT)
Copyright (c) 2017 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 and this permission notice 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
Edition: Home or Pro (Can run on other Edition AT YOUR OWN RISK)
Build: Creator's Update (Can run on other Build AT YOUR OWN RISK)
Files: This script and 'BlackViper.csv' (Service Configurations)
.DESCRIPTION
Script that can set services based on Black Viper's Service Configurations.
AT YOUR OWN RISK YOU CAN
1. Run the script on x32 w/o changing settings (But shows a warning)
2. Skip the check for
A. Home/Pro ($Script:EditionCheck variable bottom of script or use -sec switch)
B. Creator's Update ($Script:BuildCheck variable bottom of script or use -sbc switch)
.BASIC USAGE
Run script with powershell.exe -NoProfile -ExecutionPolicy Bypass -File BlackViper-Win10.ps1
or Use bat file provided
Then Use the Gui and Select the desired Choices
.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 arguments/switches (space between multiple)
--Basic Switches--
Switches Description of Switch
-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)
--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 Script.log)
-baf (Log File of Services Configuration Before and After the script)
--AT YOUR OWN RISK Switches--
-sec (Skips Edition Check by Setting Edition as Pro)
-secp ^Same as Above
-sech (Skips Edition Check by Setting Edition as Home)
-sbc (Skips Build Check)
--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)
--Misc Switches--
-sxb (Skips changes to all XBox Services)
-dry (Runs the script and shows what services will be changed)
-diag (Shows diagnostic information, Stops -auto)
-snis (Show not installed Services)
------------------------------------------------------------------------------#>
##########
# Pre-Script -Start
##########
$Script:WindowVersion = [Environment]::OSVersion.Version.Major
If($WindowVersion -ne 10) {
Clear-Host
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' }
$Script:PassedArg = $args
$Script:filebase = $PSScriptRoot + "\"
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
}
$URL_Base = "https://raw.githubusercontent.com/madbomb122/BlackViperScript/master/"
$Version_Url = $URL_Base + "Version/Version.csv"
$Service_Url = $URL_Base + "BlackViper.csv"
If([System.Environment]::Is64BitProcess){ $OSType = 64 }
$Script:ServiceEnd = (Get-Service "*_*" | Select-Object Name | Select-Object -First 1).Name.Split('_')[1]
$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
$ServicesTypeList = @(
'', #0 -Skip Not Installed
'Disabled', #1 -Disable
'Manual', #2 -Manual
'Automatic',#3 -Automatic
'Automatic')#4 -Automatic (Delayed Start)
$ServicesRegTypeList = @(
'', #0 -None
'4', #1 -Disable
'3', #2 -Manual
'2', #3 -Automatic
'2') #4 -Automatic (Delayed Start)
$XboxServiceArr = @("xbgm","XblAuthManager", "XblGameSave", "XboxNetApiSvc")
$Script:Black_Viper = 0
$Script:All_or_Min = "-min"
$Script:RunScript = 2
$Script:ErrorDi = ""
$Script:LogStarted = 0
$Script:XboxService = 0
##########
# Pre-Script -End
##########
# Multi Use Functions -Start
##########
Function ThanksDonate {
DisplayOut "`nThanks for using my script." 11 0
DisplayOut "If you like this script please consider giving me a donation." 11 0
DisplayOut "`nLink to donation:" 15 0
DisplayOut "https://www.amazon.com/gp/registry/wishlist/YBAYWBJES5DE/" 2 0
}
Function MenuBlankLineLog { DisplayOutMenu "| |" 14 0 1 1 }
Function MenuLineLog { DisplayOutMenu "|---------------------------------------------------|" 14 0 1 1 }
Function LeftLineLog { DisplayOutMenu "| " 14 0 0 1 }
Function RightLineLog { DisplayOutMenu " |" 14 0 1 1 }
Function MenuBlankLine { DisplayOutMenu "| |" 14 0 1 0 }
Function MenuLine { DisplayOutMenu "|---------------------------------------------------|" 14 0 1 0 }
Function LeftLine { DisplayOutMenu "| " 14 0 0 0 }
Function RightLine { DisplayOutMenu " |" 14 0 1 0 }
Function OpenWebsite([String]$Url) { [System.Diagnostics.Process]::Start($Url) }
Function DownloadFile([String]$Url,[String]$FilePath) { (New-Object System.Net.WebClient).DownloadFile($Url, $FilePath) }
Function ShowInvalid([Int]$InvalidA) { If($InvalidA -eq 1) { Write-Host "`nInvalid Input" -ForegroundColor Red -BackgroundColor Black -NoNewline } Return 0 }
Function LaptopCheck { $Script:PCType = (Get-WmiObject -Class Win32_ComputerSystem).PCSystemType ;If($PCType -ne 2) { Return "-Desk" } Return "-Lap" }
Function DisplayOutMenu([String]$TxtToDisplay,[Int]$TxtColor,[Int]$BGColor,[Int]$NewLine,[Int]$LogOut) {
If($NewLine -eq 0) {
If($ScriptLog -eq 1 -And $LogOut -eq 1){ Write-Output $TxtToDisplay 4>&1 | Out-File -Filepath $LogFile -NoNewline -Append }
Write-Host -NoNewline $TxtToDisplay -ForegroundColor $colors[$TxtColor] -BackgroundColor $colors[$BGColor]
} Else {
If($ScriptLog -eq 1 -And $LogOut -eq 1){ Write-Output $TxtToDisplay 4>&1 | Out-File -Filepath $LogFile -Append }
Write-Host $TxtToDisplay -ForegroundColor $colors[$TxtColor] -BackgroundColor $colors[$BGColor]
}
}
Function DisplayOut([String]$TxtToDisplay,[Int]$TxtColor,[Int]$BGColor) {
If($ScriptLog -eq 1){ Write-Output $TxtToDisplay 4>&1 | Out-File -Filepath $LogFile -Append }
Write-Host $TxtToDisplay -ForegroundColor $colors[$TxtColor] -BackgroundColor $colors[$BGColor]
}
Function AutomatedExitCheck([Int]$ExitBit) {
If($Automated -ne 1){ Read-Host -Prompt "`nPress Any key to Close..." }
If($ExitBit -eq 1){ Exit }
}
Function Error_Top_Display {
Clear-Host
DiagnosticCheck 0
MenuLineLog
LeftLineLog ;DisplayOutMenu " Error " 13 0 0 1 ;RightLineLog
MenuLineLog
MenuBlankLineLog
}
Function Error_Bottom {
MenuBlankLineLog
MenuLineLog
If($Diagnostic -eq 1) {
DiagnosticCheck 0
Read-Host -Prompt "`nPress Any key to Close..."
Exit
} Else {
AutomatedExitCheck 1
}
}
Function DiagnosticCheck([Int]$Bypass) {
If($Release_Type -ne "Stable" -or $Bypass -eq 1 -or $Diagnostic -eq 1) {
DisplayOutMenu " Diagnostic Output" 15 0 1 1
DisplayOutMenu " Some items may be blank" 15 0 1 1
DisplayOutMenu " --------Start--------" 15 0 1 1
DisplayOutMenu " Script Version = $Script_Version" 15 0 1 1
DisplayOutMenu " Script Minor Version = $Minor_Version" 15 0 1 1
DisplayOutMenu " Release Type = $Release_Type" 15 0 1 1
DisplayOutMenu " Services Version = $ServiceVersion" 15 0 1 1
DisplayOutMenu " Error = $ErrorDi" 13 0 1 1
DisplayOutMenu " Window = $WindowVersion" 15 0 1 1
DisplayOutMenu " Edition = $FullWinEdition" 15 0 1 1
DisplayOutMenu " Edition SKU# = $WinSku" 15 0 1 1
DisplayOutMenu " Build = $BuildVer" 15 0 1 1
DisplayOutMenu " Version = $Win10Ver" 15 0 1 1
DisplayOutMenu " PC Type = $PCType" 15 0 1 1
DisplayOutMenu " Desktop/Laptop = $IsLaptop" 15 0 1 1
DisplayOutMenu " ServiceConfig = $Black_Viper" 15 0 1 1
DisplayOutMenu " All/Min = $All_or_Min" 15 0 1 1
DisplayOutMenu " ToS = $AcceptToS" 15 0 1 1
DisplayOutMenu " Automated = $Automated" 15 0 1 1
DisplayOutMenu " ScriptVerCheck = $ScriptVerCheck" 15 0 1 1
DisplayOutMenu " ServiceVerCheck = $ServiceVerCheck" 15 0 1 1
DisplayOutMenu " InternetCheck = $InternetCheck" 15 0 1 1
DisplayOutMenu " ShowAlreadySet = $ShowAlreadySet" 15 0 1 1
DisplayOutMenu " ShowNonInstalled = $ShowNonInstalled" 15 0 1 1
DisplayOutMenu " ShowSkipped = $ShowSkipped" 15 0 1 1
DisplayOutMenu " EditionCheck = $EditionCheck" 15 0 1 1
DisplayOutMenu " BuildCheck = $BuildCheck" 15 0 1 1
DisplayOutMenu " Args = $PassedArg" 15 0 1 1
DisplayOutMenu " ---------End---------`n" 15 0 1 1
}
}
##########
# Multi Use Functions -End
##########
# TOS -Start
##########
Function TOSDisplay {
Clear-Host
$BorderColor = 14
If($Release_Type -ne "Stable") {
$BorderColor = 15
DisplayOut "|---------------------------------------------------|" $BorderColor 0 1
DisplayOutMenu "| " $BorderColor 0 0 ;DisplayOutMenu " Caution!!! " 13 0 0 ;DisplayOut " |" $BorderColor 0 1
DisplayOut "| |" $BorderColor 0 1
DisplayOutMenu "| " $BorderColor 0 0 ;DisplayOutMenu " This script is still being tested. " 14 0 0 ;DisplayOut " |" $BorderColor 0 1
DisplayOutMenu "| " $BorderColor 0 0 ;DisplayOutMenu " USE AT YOUR OWN RISK. " 14 0 0 ;DisplayOut " |" $BorderColor 0 1
DisplayOut "| |" $BorderColor 0 1
}
If($OSType -ne 64) {
$BorderColor = 15
DisplayOut "|---------------------------------------------------|" $BorderColor 0 1
DisplayOutMenu "| " $BorderColor 0 0 ;DisplayOutMenu " WARNING!! " 13 0 0 ;DisplayOut " |" $BorderColor 0 1
DisplayOut "| |" $BorderColor 0 1
DisplayOutMenu "| " $BorderColor 0 0 ;DisplayOutMenu " These settings are ment for x64 Bit. " 14 0 0 ;DisplayOut " |" $BorderColor 0 1
DisplayOutMenu "| " $BorderColor 0 0 ;DisplayOutMenu " USE AT YOUR OWN RISK. " 14 0 0 ;DisplayOut " |" $BorderColor 0 1
DisplayOut "| |" $BorderColor 0 1
}
DisplayOut "|---------------------------------------------------|" $BorderColor 0 1
DisplayOutMenu "| " $BorderColor 0 0 ;DisplayOutMenu " Terms of Use " 11 0 0 ;DisplayOut " |" $BorderColor 0 1
DisplayOut "|---------------------------------------------------|" $BorderColor 0 1
DisplayOut "| |" $BorderColor 0 1
DisplayOutMenu "| " $BorderColor 0 0 ;DisplayOutMenu "This program comes with ABSOLUTELY NO WARRANTY. " 2 0 0 ;DisplayOut " |" $BorderColor 0 1
DisplayOutMenu "| " $BorderColor 0 0 ;DisplayOutMenu "This is free software, and you are welcome to " 2 0 0 ;DisplayOut " |" $BorderColor 0 1
DisplayOutMenu "| " $BorderColor 0 0 ;DisplayOutMenu "redistribute it under certain conditions. " 2 0 0 ;DisplayOut " |" $BorderColor 0 1
DisplayOut "| |" $BorderColor 0 1
DisplayOutMenu "| " $BorderColor 0 0 ;DisplayOutMenu "Read License file for full Terms. " 2 0 0 ;DisplayOut " |" $BorderColor 0 1
DisplayOut "| |" $BorderColor 0 1
DisplayOut "|---------------------------------------------------|" $BorderColor 0 1
}
Function TOS {
While($TOS -ne "Out") {
TOSDisplay
$Invalid = ShowInvalid $Invalid
$TOS = Read-Host "`nDo you Accept? (Y)es/(N)o"
Switch($TOS.ToLower()) {
{$_ -eq "n" -or $_ -eq "no"} { Exit ;Break }
{$_ -eq "y" -or $_ -eq "yes"} { $TOS = "Out" ;TOSyes ;Break }
Default { $Invalid = 1 ;Break }
}
} Return
}
Function TOSyes {
$Script:AcceptToS = "Accepted-Script"
$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
}
}
##########
# TOS -End
##########
# GUI -Start
##########
Function Update-Window {
[cmdletBinding()]
Param($Control,$Property,$Value,[Switch]$AppendContent)
If($Property -eq "Close"){ $syncHash.Window.Dispatcher.invoke([action]{$syncHash.Window.Close()},"Normal") ;Return }
$form.Dispatcher.Invoke([Action]{ If($PSBoundParameters['AppendContent']){ $Control.AppendText($Value) } Else{ $Control.$Property = $Value } }, "Normal")
}
Function OpenSaveDiaglog([Int]$SorO) {
If($SorO -eq 0){ $SOFileDialog = New-Object System.Windows.Forms.OpenFileDialog } Else{ $SOFileDialog = New-Object System.Windows.Forms.SaveFileDialog }
$SOFileDialog.InitialDirectory = $filebase
If($SorO -ne 2){ $SOFileDialog.Filter = "CSV (*.csv)| *.csv" } Else{ $SOFileDialog.Filter = "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 HideCustomSrvStuff {
$WPF_LoadServicesButton.IsEnabled = $True
$WPF_RadioAll.IsEnabled = $True
$WPF_RadioMin.IsEnabled = $True
ForEach($Var In $CNoteList){ $Var.Value.Visibility = 'Hidden' }
$WPF_LoadFileTxtBox.Visibility = 'Hidden'
$WPF_btnOpenFile.Visibility = 'Hidden'
}
Function GuiStart {
Clear-Host
DisplayOutMenu "Preparing GUI, Please wait..." 15 0 1 0
$TPath = $filebase + "BlackViper.csv"
If(Test-Path $TPath -PathType Leaf) {
$TMP = Import-Csv $TPath
$ServiceVersion = ($TMP[0]."Def-Home-Full")
$ServiceDate = ($TMP[0]."Def-Home-Min")
} Else {
$ServiceVersion = "Missing File"
$ServiceDate = "BlackViper.csv"
}
[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="330" Width="490" BorderBrush="Black" Background="White">
<Window.Effect> <DropShadowEffect/></Window.Effect><Grid>
<Label Content="Service Version:" HorizontalAlignment="Left" Margin="256,0,0,-1" VerticalAlignment="Bottom" Height="25"/>
<Label Content="Script Version:" HorizontalAlignment="Left" Margin="1,0,0,-1" VerticalAlignment="Bottom" Height="25"/>
<Button Name="CopyrightButton" Content="Copyright" HorizontalAlignment="Left" Margin="114,0,0,21" VerticalAlignment="Bottom" Width="114" FontStyle="Italic" Background="#FF8ABEF0"/>
<Button Name="BlackViperWSButton" Content="BlackViper's Website" HorizontalAlignment="Left" Margin="228,0,0,21" VerticalAlignment="Bottom" Width="117" FontStyle="Italic" Background="#FFA7D24D"/>
<Button Name="Madbomb122WSButton" Content="Madbomb122's Website" HorizontalAlignment="Left" Margin="345,0,0,21" VerticalAlignment="Bottom" Width="129" FontStyle="Italic" Background="#FFA7D24D"/>
<Button Name="DonateButton" Content="Donate to me" HorizontalAlignment="Left" Margin="0,0,0,21" VerticalAlignment="Bottom" Width="114" FontStyle="Italic" Background="#FFFFAD2F"/>
<Button Name="RunScriptButton" Content="Run Script" HorizontalAlignment="Left" Margin="0,0,0,42" VerticalAlignment="Bottom" Width="474" Height="20" FontWeight="Bold"/>
<TextBox Name="Script_Ver_Txt" HorizontalAlignment="Left" Height="20" Margin="82,0,0,0" TextWrapping="Wrap" Text="2.8.0 (6-21-2017)" VerticalAlignment="Bottom" Width="125" IsEnabled="False"/>
<TextBox Name="Service_Ver_Txt" HorizontalAlignment="Left" Height="20" Margin="345,0,0,0" TextWrapping="Wrap" Text="2.0 (5-21-2017)" VerticalAlignment="Bottom" Width="129" IsEnabled="False"/>
<TextBox Name="Release_Type_Txt" HorizontalAlignment="Left" Height="20" Margin="207,0,0,0" TextWrapping="Wrap" Text="Testing" VerticalAlignment="Bottom" Width="48" IsEnabled="False"/>
<TabControl Name="TabControl" Margin="0,0,0,65">
<TabItem Name="Services_Tab" Header="Services Options" Margin="-2,0,2,0"><Grid Background="#FFE5E5E5">
<Label Content="Service Configurations:" HorizontalAlignment="Left" Margin="2,63,0,0" VerticalAlignment="Top" Height="27" Width="146" FontWeight="Bold"/>
<ComboBox Name="ServiceConfig" HorizontalAlignment="Left" Margin="139,66,0,0" VerticalAlignment="Top" Width="118" Height="23">
<ComboBoxItem Content="Default" HorizontalAlignment="Left" Width="116" IsSelected="True"/>
<ComboBoxItem Content="Safe" HorizontalAlignment="Left" Width="116"/>
<ComboBoxItem Content="Tweaked" HorizontalAlignment="Left" Width="116"/>
<ComboBoxItem Content="Custom Setting *" HorizontalAlignment="Left" Width="116"/>
</ComboBox>
<RadioButton Name="RadioAll" Content="All -Change All Services" HorizontalAlignment="Left" Margin="5,26,0,0" VerticalAlignment="Top" IsChecked="True"/>
<RadioButton Name="RadioMin" Content="Min -Change Services that are Different from Default to Safe/Tweaked" HorizontalAlignment="Left" Margin="5,41,0,0" VerticalAlignment="Top"/>
<Label Content="Black Viper Configuration Options (BV Services Only)" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="2,3,0,0" FontWeight="Bold"/>
<Label Name="CustomNote1" Content="*Note: Configure Below" HorizontalAlignment="Left" Margin="262,63,0,0" VerticalAlignment="Top" Width="148" Height="27" FontWeight="Bold"/>
<Rectangle Fill="#FFFFFFFF" Height="1" Margin="0,97,-6,0" Stroke="Black" VerticalAlignment="Top"/>
<Button Name="btnOpenFile" Content="Browse File" HorizontalAlignment="Left" Margin="5,120,0,0" VerticalAlignment="Top" Width="66" Height="22"/>
<TextBox Name="LoadFileTxtBox" HorizontalAlignment="Left" Height="50" Margin="5,150,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="461" IsReadOnly="True" Background="#FFECECEC"/>
<Label Name="CustomNote3" Content="Config File: Browse for file" HorizontalAlignment="Left" Margin="76,118,0,0" VerticalAlignment="Top" FontWeight="Bold"/>
<Label Name="CustomNote2" Content="Custom Configuration" HorizontalAlignment="Left" Margin="164,95,0,0" VerticalAlignment="Top" Width="135" Height="26" FontWeight="Bold"/></Grid>
</TabItem>
<TabItem Name="Options_tab" Header="Script Options" Margin="-2,0,2,0"><Grid Background="#FFE5E5E5">
<Label Content="Display Options" HorizontalAlignment="Left" Margin="4,5,0,0" VerticalAlignment="Top" FontWeight="Bold"/>
<Label Content="Log Options" HorizontalAlignment="Left" Margin="4,138,0,0" VerticalAlignment="Top" FontWeight="Bold"/>
<Label Content="Misc Options" HorizontalAlignment="Left" Margin="4,67,0,0" VerticalAlignment="Top" FontWeight="Bold"/>
<CheckBox Name="Dryrun_CB" Content="Dryrun -Shows what will be changed" HorizontalAlignment="Left" Margin="9,90,0,0" VerticalAlignment="Top" Height="15" Width="213"/>
<CheckBox Name="LogBeforeAfter_CB" Content="Services Before and After" HorizontalAlignment="Left" Margin="9,160,0,0" VerticalAlignment="Top" Height="16" Width="158"/>
<CheckBox Name="ShowAlreadySet_CB" Content="Show Already Set Services" HorizontalAlignment="Left" Margin="9,28,0,0" VerticalAlignment="Top" Height="15" Width="158" IsChecked="True"/>
<CheckBox Name="ShowNonInstalled_CB" Content="Show Not Installed Services" HorizontalAlignment="Left" Margin="9,43,0,0" VerticalAlignment="Top" Height="15" Width="166"/>
<CheckBox Name="ScriptLog_CB" Content="Script Log:" HorizontalAlignment="Left" Margin="9,176,0,0" VerticalAlignment="Top" Height="18" Width="76"/>
<CheckBox Name="XboxService_CB" Content="Skip All Xbox Services" HorizontalAlignment="Left" Margin="9,105,0,0" VerticalAlignment="Top" Height="15" Width="218"/>
<CheckBox Name="BackupServiceConfig_CB" Content="Backup Current Service as:" HorizontalAlignment="Left" Margin="9,120,0,0" VerticalAlignment="Top" Height="15" Width="162"/>
<ComboBox Name="BackupServiceType" HorizontalAlignment="Left" Margin="171,117,0,0" VerticalAlignment="Top" Width="52" Height="23">
<ComboBoxItem Content=".reg" HorizontalAlignment="Left" Width="50"/>
<ComboBoxItem Content=".csv" HorizontalAlignment="Left" Width="50" IsSelected="True"/>
<ComboBoxItem Content="Both" HorizontalAlignment="Left" Width="50"/>
</ComboBox>
<TextBox Name="LogNameInput" HorizontalAlignment="Left" Height="20" Margin="87,174,0,0" TextWrapping="Wrap" Text="Script.log" VerticalAlignment="Top" Width="140" IsEnabled="False"/>
<CheckBox Name="ScriptVerCheck_CB" Content="Script Update*" HorizontalAlignment="Left" Margin="244,105,0,0" VerticalAlignment="Top" Height="15" Width="99"/>
<CheckBox Name="BatUpdateScriptFileName_CB" Content="Update Bat file with new Script file**" HorizontalAlignment="Left" Margin="244,120,0,0" VerticalAlignment="Top" Height="15" Width="214"/>
<CheckBox Name="ServiceUpdateCB" Content="Service Update" HorizontalAlignment="Left" Margin="244,90,0,0" VerticalAlignment="Top" Height="15" Width="99"/>
<CheckBox Name="InternetCheck_CB" Content="Skip Internet Check" HorizontalAlignment="Left" Margin="244,135,0,0" VerticalAlignment="Top" Height="15" Width="124"/>
<Label Content="*Will run and use current settings
**If update.bat isnt avilable" HorizontalAlignment="Left" Margin="238,144,0,0" VerticalAlignment="Top" FontWeight="Bold"/>
<Label Content="Update Items" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="239,67,0,0" FontWeight="Bold"/>
<CheckBox Name="BuildCheck_CB" Content="Skip Build Check" HorizontalAlignment="Left" Margin="244,28,0,0" VerticalAlignment="Top" Height="15" Width="110"/>
<CheckBox Name="EditionCheck_CB" Content="Skip Edition Check Set as :" HorizontalAlignment="Left" Margin="244,43,0,0" VerticalAlignment="Top" Height="15" Width="160"/>
<ComboBox Name="EditionConfig" HorizontalAlignment="Left" Margin="404,40,0,0" VerticalAlignment="Top" Width="60" Height="23">
<ComboBoxItem Content="Home" HorizontalAlignment="Left" Width="58"/>
<ComboBoxItem Content="Pro" HorizontalAlignment="Left" Width="58" IsSelected="True"/>
</ComboBox>
<Label Content="SKIP CHECK AT YOUR OWN RISK!" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="238,5,0,0" FontWeight="Bold"/>
<Rectangle Fill="#FFFFFFFF" HorizontalAlignment="Left" Margin="236,-3,0,-1" Stroke="Black" Width="1"/></Grid>
</TabItem>
<TabItem Name="ServicesCB_Tab" Header="Services List" Margin="-2,0,2,0"><Grid Background="#FFE5E5E5">
<DataGrid Name="dataGrid" AutoGenerateColumns="False" AlternationCount="1" SelectionMode="Single" IsReadOnly="True" HeadersVisibility="Column" Margin="-2,38,0,-2" AlternatingRowBackground="#FFD8D8D8" CanUserResizeRows="False" ><DataGrid.Columns>
<DataGridCheckBoxColumn Binding="{Binding checkboxChecked, UpdateSourceTrigger=PropertyChanged}"><DataGridCheckBoxColumn.ElementStyle>
<Style TargetType="CheckBox"/></DataGridCheckBoxColumn.ElementStyle></DataGridCheckBoxColumn>
<DataGridTextColumn Header="Common Name" Width="121" Binding="{Binding CName}"/>
<DataGridTextColumn Header="Service Name" Width="120" Binding="{Binding ServiceName}"/>
<DataGridTextColumn Header="Current Setting" Width="95" Binding="{Binding CurrType}"/>
<DataGridTextColumn Header="Black Viper" Width="95" Binding="{Binding BVType}"/>
</DataGrid.Columns></DataGrid>
<Rectangle Fill="#FFFFFFFF" Height="1" Margin="-2,37,2,0" Stroke="Black" VerticalAlignment="Top"/>
<Button Name="SaveCustomSrvButton" Content="Save Current" HorizontalAlignment="Left" Margin="103,1,0,0" VerticalAlignment="Top" Width="80" Visibility="Hidden"/>
<Button Name="SaveRegButton" Content="Save Registry" HorizontalAlignment="Left" Margin="198,1,0,0" VerticalAlignment="Top" Width="80" Visibility="Hidden"/>
<Button Name="LoadServicesButton" Content="Load Services" HorizontalAlignment="Left" Margin="3,1,0,0" VerticalAlignment="Top" Width="76"/>
<Label Name="ServiceNote" Content="Uncheck what you "Don't want to be changed"" HorizontalAlignment="Left" Margin="196,15,0,0" VerticalAlignment="Top" Visibility="Hidden"/>
<Label Name="ServiceLegendLabel" Content="Service -> Current -> Changed To" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="-2,15,0,0" Visibility="Hidden"/>
<Label Name="ServiceClickLabel" Content="<-- Click to load Service List" HorizontalAlignment="Left" Margin="75,-3,0,0" VerticalAlignment="Top"/>
<CheckBox Name="CustomBVCB" Content="Use Checked Services" HorizontalAlignment="Left" Margin="288,3,0,0" VerticalAlignment="Top" Width="158" RenderTransformOrigin="0.696,0.4" Visibility="Hidden"/></Grid>
</TabItem>
<TabItem Name="Dev_Option_Tab" Header="Dev Option/Contact/About" Margin="-2,0,2,0"><Grid Background="#FFE5E5E5">
<CheckBox Name="Diagnostic_CB" Content="Diagnostic Output (On Error)" HorizontalAlignment="Left" Margin="9,18,0,0" VerticalAlignment="Top" Height="15" Width="174"/>
<CheckBox Name="DevLog_CB" Content="Dev Log" HorizontalAlignment="Left" Margin="9,33,0,0" VerticalAlignment="Top" Height="15" Width="174"/>
<Button Name="EMail" Content="e-mail Madbomb122" HorizontalAlignment="Left" Margin="12,66,0,0" VerticalAlignment="Top" Width="123"/>
<Label Content="If your having problems email me

e-mail: [email protected]" HorizontalAlignment="Left" Margin="200,10,0,0" VerticalAlignment="Top" Width="190"/>
<Label Content="<-- with a 'Dev Log' if asked to." HorizontalAlignment="Left" Margin="178,26,0,0" VerticalAlignment="Top"/>
<Label Content="Please check FAQ on my GitHub before contacting me." HorizontalAlignment="Left" Margin="135,63,0,0" VerticalAlignment="Top" FontWeight="Bold"/>
<Rectangle Fill="#FFFFFFFF" Height="1" Margin="0,90,0,0" Stroke="Black" VerticalAlignment="Top"/>
<Label Content="This script lets you set Windows 10's services based on Black Viper's Service 
Configurations, your own Service Configuration (If in a proper format), or a backup 
of your Service Configurations made by this script.

This script was created by MadBomb122." HorizontalAlignment="Left" Margin="11,101,0,0" VerticalAlignment="Top" Width="450" Height="91"/></Grid>
</TabItem>
</TabControl>
<Rectangle Fill="#FFFFFFFF" Height="1" Margin="0,0,0,62" Stroke="Black" VerticalAlignment="Bottom"/>
<Rectangle Fill="#FFFFFFFF" Height="1" Margin="0,0,0,41" Stroke="Black" VerticalAlignment="Bottom"/>
<Rectangle Fill="#FFFFFFFF" Height="1" Margin="0,0,0,20" Stroke="Black" VerticalAlignment="Bottom"/>
<Rectangle Fill="#FFFFFFFF" HorizontalAlignment="Left" Margin="255,0,0,0" Stroke="Black" Width="1" Height="20" VerticalAlignment="Bottom"/></Grid>
</Window>
"@
[void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework')
$reader = (New-Object System.Xml.XmlNodeReader $xaml)
$Form = [Windows.Markup.XamlReader]::Load( $reader )
$xaml.SelectNodes("//*[@Name]") | ForEach-Object{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]$VarList = Get-Variable "WPF_*_CB"
[System.Collections.ArrayList]$CNoteList = Get-Variable "WPF_CustomNote*"
$Script:WinSkuList = @(48,49,98,100,101)
$WPF_ServiceConfig.add_SelectionChanged({
If(($WPF_ServiceConfig.SelectedIndex+1) -eq $BVCount) {
$WPF_RadioAll.IsEnabled = $False
$WPF_RadioMin.IsEnabled = $False
ForEach($Var In $CNoteList){ $Var.Value.Visibility = 'Visible' }
$WPF_LoadFileTxtBox.Visibility = 'Visible'
$WPF_btnOpenFile.Visibility = 'Visible'
} Else {
HideCustomSrvStuff
}
RunDisableCheck
})
$WPF_RunScriptButton.Add_Click({
$Script:RunScript = 1
$Black_Viper = $WPF_ServiceConfig.SelectedIndex + 1
If($Black_Viper -eq $BVCount) {
If(!(Test-Path $ServiceConfigFile -PathType Leaf) -And $ServiceConfigFile -ne $null) {
[Windows.Forms.MessageBox]::Show("The File '$ServiceConfigFile' does not exist","Error", 'OK')
$Script:RunScript = 0
} Else {
$Script:LoadServiceConfig = 1
$Script:Black_Viper = 0
}
}
If($RunScript -eq 1){ GuiDone } Else{ RunDisableCheck }
})
$WPF_ScriptLog_CB.Add_Checked({ $WPF_LogNameInput.IsEnabled = $True })
$WPF_ScriptLog_CB.Add_UnChecked({ $WPF_LogNameInput.IsEnabled = $False })
$WPF_CustomBVCB.Add_Checked({ RunDisableCheck ;$WPF_SaveCustomSrvButton.content = "Save Selection" })
$WPF_CustomBVCB.Add_UnChecked({ RunDisableCheck ;$WPF_SaveCustomSrvButton.content = "Save Current" })
$WPF_btnOpenFile.Add_Click({ OpenSaveDiaglog 0 })
$WPF_SaveCustomSrvButton.Add_Click({ OpenSaveDiaglog 1 })
$WPF_SaveRegButton.Add_Click({ OpenSaveDiaglog 2 })
$WPF_EMail.Add_Click({ OpenWebsite "mailto:[email protected]" })
$WPF_BuildCheck_CB.Add_Click({ RunDisableCheck })
$WPF_EditionCheck_CB.Add_Click({ RunDisableCheck })
$WPF_BlackViperWSButton.Add_Click({ OpenWebsite "http://www.blackviper.com/" })
$WPF_Madbomb122WSButton.Add_Click({ OpenWebsite "https://github.com/madbomb122/" })
$WPF_DonateButton.Add_Click({ OpenWebsite "https://www.amazon.com/gp/registry/wishlist/YBAYWBJES5DE/" })
$WPF_LoadServicesButton.Add_Click({ GenerateServices })
$WPF_CopyrightButton.Add_Click({ [Windows.Forms.MessageBox]::Show($CopyrightItems,"Copyright", 'OK') })
$CopyrightItems = 'Copyright (c) 1999-2017 Charles "Black Viper" Sparks - Services Configuration
The MIT License (MIT)
Copyright (c) 2017 Madbomb122 - Black Viper Service Configuration 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 and this permission notice 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.'
$Skip_Services = @(
"PimIndexMaintenanceSvc_",
"DevicesFlowUserSvc_",
"UserDataSvc_",
"UnistoreSvc_",
"WpnUserService_",
"AppXSVC",
"BrokerInfrastructure",
"ClipSVC",
"CoreMessagingRegistrar",
"DcomLaunch",
"EntAppSvc",
"gpsvc",
"LSM",
"NgcSvc",
"NgcCtnrSvc",
"RpcSs",
"RpcEptMapper",
"sppsvc",
"StateRepository",
"SystemEventsBroker",
"Schedule",
"tiledatamodelsvc",
"WdNisSvc",
"SecurityHealthService",
"msiserver",
"MpsSvc",
"WinDefend")
#"xbgm")
For($i=0;$i -ne 5;$i++){ $Skip_Services[$i] = $Skip_Services[$i] + $ServiceEnd }
$Script:CurrServices = Get-Service | Select-Object DisplayName, Name, StartType
$Script:RunScript = 0
If($All_or_Min -eq "-full"){ $WPF_RadioAll.IsChecked = $True } Else{ $WPF_RadioMin.IsChecked = $True }
If($ScriptLog -eq 1) {
$WPF_ScriptLog_CB.IsChecked = $True
$WPF_LogNameInput.IsEnabled = $True
} Else {
$WPF_LogNameInput.IsEnabled = $False
}
If($IsLaptop -eq "-Lap"){ $WPF_ServiceConfig.Items.RemoveAt(2) }
$Script:BVCount = $WPF_ServiceConfig.Items.Count
ForEach($Var In $VarList){ If($(Get-Variable -Name ($Var.Name.Split('_')[1]) -ValueOnly) -eq 1){ $Var.Value.IsChecked = $True } Else{ $Var.Value.IsChecked = $False } }
If($WinEdition -eq "Home" -or $EditionCheck -eq "Home"){ $WPF_EditionConfig.SelectedIndex = 0 } Else{ $WPF_EditionConfig.SelectedIndex = 1 }
If($EditionCheck -eq "Pro" -or $EditionCheck -eq "Home"){ $WPF_EditionConfig.IsEnabled = $True } Else{ $WPF_EditionCheck_CB.IsChecked = $False }
$WPF_BackupServiceType.SelectedIndex = 0
$WPF_LoadFileTxtBox.Text = $ServiceConfigFile
$WPF_LogNameInput.Text = $LogName
$WPF_Script_Ver_Txt.Text = "$Script_Version.$Minor_Version ($Script_Date)"
$WPF_Service_Ver_Txt.Text = "$ServiceVersion ($ServiceDate)"
$WPF_Release_Type_Txt.Text = $Release_Type
$Script:ServiceImport = 1
HideCustomSrvStuff
RunDisableCheck
Clear-Host
DisplayOutMenu "Displaying GUI Now" 14 0 1 0
$Form.ShowDialog() | Out-Null
}
Function RunDisableCheck {
If($WPF_BuildCheck_CB.IsChecked){ $Script:BuildCheck = 1 } Else{ $Script:BuildCheck = 0 }
If($WPF_EditionCheck_CB.IsChecked) {
$Script:EditionCheck = $WPF_EditionConfig.Text
$WPF_EditionConfig.IsEnabled = $True
} Else {
$Script:EditionCheck = 0
$WPF_EditionConfig.IsEnabled = $False
}
$EBFailCount = 0
If(!($EditionCheck -eq "Home" -or $EditionCheck -eq "Pro" -or $WinSkuList -Contains $WinSku)){ $EBFailCount++ }
If($Win10Ver -lt $MinVer -And $BuildCheck -ne 1){ $EBFailCount += 2 }
If($EBFailCount -ne 0) {
$Buttontxt = "Run Disabled Due to "
If($EBFailCount -eq 3) {
$Buttontxt += "Edition & Build"
} ElseIf($EBFailCount -eq 1) {
$Buttontxt += "Edition"
} Else {
$Buttontxt += "Build"
}
$WPF_RunScriptButton.IsEnabled = $False
$Buttontxt += " Check"
$WPF_dataGrid.Columns[4].Header = "Black Viper"
} ElseIf($WPF_ServiceConfig.SelectedIndex + 1 -eq $BVCount) {
If(!($ServiceConfigFile) -or !(Test-Path $ServiceConfigFile -PathType Leaf)) {
$WPF_RunScriptButton.IsEnabled = $False
$WPF_LoadServicesButton.IsEnabled = $False
$Buttontxt = "Run Disabled, No Custom Service List File Selected or Doesn't exist."
} Else {
$WPF_LoadServicesButton.IsEnabled = $True
$WPF_RunScriptButton.IsEnabled = $True
$Buttontxt = "Run Script with Custom Service List"
}
$WPF_dataGrid.Columns[4].Header = "Custom Service"
} Else {
$WPF_dataGrid.Columns[4].Header = "Black Viper"
If($WPF_CustomBVCB.IsChecked){ $Buttontxt = "Run Script with Checked Services" } Else{ $Buttontxt = "Run Script" }
$WPF_RunScriptButton.IsEnabled = $True
}
$WPF_RunScriptButton.content = $Buttontxt
}
Function GuiDone {
ForEach($Var In $VarList) {
If($Var.Value.IsChecked){ $SetValue = 1 } Else{ $SetValue = 0 }
Set-Variable -Name ($Var.Name.Split('_')[1]) -Value $SetValue -Scope Script
}
If($WPF_RadioAll.IsChecked){ $Script:All_or_Min = "-full" } Else{ $Script:All_or_Min = "-min" }
If($WPF_ScriptLog_CB.IsChecked){ $Script:LogName = $WPF_LogNameInput.Text }
If($WPF_EditionCheck_CB.IsChecked){ $Script:EditionCheck = $WPF_EditionConfig.Text }
If($WPF_CustomBVCB.IsChecked){ GetCustomBV }
If($WPF_BackupServiceConfig_CB.IsChecked){ $Script:BackupServiceType = $WPF_BackupServiceType.SelectedIndex }
$Form.Close()
Black_Viper_Set $Black_Viper $All_or_Min
}
Function GenerateServices {
$Black_Viper = $WPF_ServiceConfig.SelectedIndex + 1
If($Black_Viper -eq $BVCount) {
If($Script:ServiceGen -eq 0){ $Script:ServiceImport = 1 }
$Script:LoadServiceConfig = 1
$ServiceFilePath = $WPF_LoadFileTxtBox.Text
$ServiceGen = 1
} Else {
If($Script:ServiceGen -eq 1){ $Script:ServiceImport = 1 }
If($WPF_RadioAll.IsChecked){ $FullMin = "-Full" } Else{ $FullMin = "-Min" }
$Script:LoadServiceConfig = 0
$ServiceFilePath = $filebase + "BlackViper.csv"
$ServiceGen = 0
}
Switch($Black_Viper) {
{$LoadServiceConfig -eq 1} { $Script:BVService = "StartType" ;Break }
1 { ($Script:BVService="Def-"+$WinEdition+$FullMin) ;$BVSAlt = "Def-"+$WinEdition+"-Full" ;Break }
2 { ($Script:BVService="Safe"+$IsLaptop+$FullMin) ;$BVSAlt = "Safe"+$IsLaptop+"-Full" ;Break }
3 { ($Script:BVService="Tweaked"+$IsLaptop+$FullMin) ;$BVSAlt = "Tweaked"+$IsLaptop+"-Full" ;Break }
}
If($WPF_XboxService_CB.IsChecked){ $Script:XboxService = 1 } Else{ $Script:XboxService = 0 }
If($ServiceImport -eq 1) {
[System.Collections.ArrayList]$ServCB = Import-Csv $ServiceFilePath
$ServiceImport = 0
}
[System.Collections.ArrayList]$DataGridList = @()
ForEach($item In $ServCB) {
$SName = $($item.ServiceName)
If($SName -Like "*_*"){ $SName = $SName.Split('_')[0] + "_$ServiceEnd" }
If($CurrServices.Name -Contains $SName) {
$ServiceTypeNum = $($item.$BVService)
$ServiceCurrType = ($CurrServices.Where{$_.Name -eq $SName}).StartType
If($ServiceTypeNum -eq 0) {
$checkbox = $False
$ServiceTypeNum = $($item.$BVSAlt)
} ElseIf($XboxService -eq 1 -and $XboxServiceArr -Contains $SName) {
$checkbox = $False
} Else {
$checkbox = $True
}
$ServiceType = $ServicesTypeList[$ServiceTypeNum]
If($ServiceTypeNum -eq 4){ $ServiceType += " (Delayed Start)" }
If($SName -Is [system.array]){ $SName = $SName[0] }
$ServiceCommName = ($CurrServices.Where{$_.Name -eq $SName}).DisplayName
$DataGridList += New-Object PSObject -Property @{ checkboxChecked = $checkbox ;CName=$ServiceCommName ;ServiceName = $SName ;CurrType = $ServiceCurrType ;BVType = $ServiceType ;StartType = $ServiceTypeNum }
}
}
$WPF_dataGrid.ItemsSource = $DataGridList
$WPF_dataGrid.Items.Refresh()
If(!($ServicesGenerated)) {
$WPF_ServiceClickLabel.Visibility = 'Hidden'
$WPF_ServiceLegendLabel.Visibility = 'Visible'
$WPF_ServiceNote.Visibility = 'Visible'
$WPF_CustomBVCB.Visibility = 'Visible'
$WPF_SaveCustomSrvButton.Visibility = 'Visible'
$WPF_SaveRegButton.Visibility = 'Visible'
$WPF_LoadServicesButton.content = "Reload"
$Script:ServicesGenerated = $True
}
}
Function GetCustomBV {
$Script:LoadServiceConfig = 2
[System.Collections.ArrayList]$Script:csvTemp = @()
$ServiceCBList = $WPF_dataGrid.Items.Where({$_.checkboxChecked -eq $true})
ForEach($item In $ServiceCBList){ $Script:csvTemp+= New-Object PSObject -Property @{ ServiceName = $item.ServiceName ;StartType = $item.StartType } }
[System.Collections.ArrayList]$Script:csv = $Script:csvTemp
}
##########
# GUI -End
##########
Function LoadWebCSV([Int]$ErrorChoice) {
If($ErrorChoice -eq 0){
$Script:ErrorDi = "Missing File BlackViper.csv -LoadCSV"
$Pick = " is Missing. "
} ElseIf($ErrorChoice -eq 1) {
$Script:ErrorDi = "Invalid/Corrupt BlackViper.csv"
$Pick = " is Invalid or Corrupt. "
} Else {
$Script:ErrorDi = "BlackViper.csv Not Valid for current Update"
$Pick = " needs to be Updated. "
}
While($LoadWebCSV -ne "Out") {
Error_Top_Display
LeftLine ;DisplayOutMenu " The File " 2 0 0 ;DisplayOutMenu "BlackViper.csv" 15 0 0 ;DisplayOutMenu "$Pick" 2 0 0 ;RightLine
MenuBlankLine
LeftLine ;DisplayOutMenu " Do you want to download " 2 0 0 ;DisplayOutMenu "BlackViper.csv" 15 0 0 ;DisplayOutMenu "? " 2 0 0 ;RightLine
MenuBlankLine
MenuLine
$Invalid = ShowInvalid $Invalid
$LoadWebCSV = Read-Host "`nDownload? (Y)es/(N)o"
Switch($LoadWebCSV.ToLower()) {
{ $_ -eq "n" -or $_ -eq "no" } { DisplayOutMenu "For download manually save the following " 2 0 1 ;DisplayOutMenu "https://github.com/madbomb122/BlackViperScript/raw/master/BlackViper.csv" 15 0 0 ;Exit ;Break }
{ $_ -eq "y" -or $_ -eq "yes" } { DownloadFile $Service_Url $ServiceFilePath ;$LoadWebCSV = "Out" ;Break }
Default { $Invalid = 1 ;Break }
}
}
If($ErrorChoice -In 1..2){ [System.Collections.ArrayList]$Script:csv = Import-Csv $ServiceFilePath }
CheckBVcsv
Return
}
Function ServiceBAfun([String]$ServiceBA) {
If($LogBeforeAfter -eq 1) {
$ServiceBAFile = $filebase + $ServiceBA + ".log"
If($ServiceBA -eq "Services-Before"){ $CurrServices | Out-File $ServiceBAFile } Else{ Get-Service | Select-Object DisplayName, StartType | Out-File $ServiceBAFile }
Get-Service | Select-Object DisplayName, StartType | Out-File $ServiceBAFile
} ElseIf($LogBeforeAfter -eq 2) {
If($ServiceBA -eq "Services-Before"){ $TMPServices = $CurrServices } Else{ $TMPServices = Get-Service | Select-Object DisplayName, Name, StartType }
Write-Output "`n$ServiceBA -Start" 4>&1 | Out-File -Filepath $LogFile -Append
Write-Output "-------------------------------------" 4>&1 | Out-File -Filepath $LogFile -Append
Write-Output $TMPServices 4>&1 | Out-File -Filepath $LogFile -Append
Write-Output "-------------------------------------" 4>&1 | Out-File -Filepath $LogFile -Append
Write-Output "$ServiceBA -End" 4>&1 | Out-File -Filepath $LogFile -Append
Write-Output " " 4>&1 | Out-File -Filepath $LogFile -Append
}
}
Function Save_Service([String]$SavePath) {
$ServiceSavePath = $filebase + $Env:computername
$SaveService = @()
If($WPF_CustomBVCB.IsChecked) {
$ServiceSavePath += "-Custom-Service.csv"
$ServiceCBList = $WPF_dataGrid.Items.Where({$_.checkboxChecked -eq $true})
ForEach($item In $ServiceCBList) {
$ServiceName = $item.ServiceName
If($ServiceName -Like "*_*"){ $ServiceName = $ServiceName.Split('_')[0] + "?????" }
$SaveService += New-Object PSObject -Property @{ ServiceName = $ServiceName ;StartType = $item.StartType }
}
} Else {
If($AllService -eq $null) {
$ServiceSavePath += "-Service-Backup.csv"
$AllService = Get-Service | Select-Object Name, StartType
} Else {
$ServiceSavePath += "-Custom-Service.csv"
}
ForEach($Service In $AllService) {
$ServiceName = $Service.Name
If(!($Skip_Services -Contains $ServiceName)) {
Switch("$($Service.StartType)") {
"Disabled" { $StartType = 1 ;Break }
"Manual" { $StartType = 2 ;Break }
"Automatic" { $exists = (Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\$ServiceName\").DelayedAutostart ;If($exists -eq 1){ $StartType = 4 } Else{ $StartType = 3 } ;Break }
Default { $StartType = "$($Service.StartType)" ;Break }
}
If($ServiceName -Like "*_*"){ $ServiceName = $ServiceName.Split('_')[0] + "?????" }
$SaveService += New-Object PSObject -Property @{ ServiceName = $ServiceName ;StartType = $StartType }
}
}
}
If($SavePath -ne $null){ $ServiceSavePath = $SavePath}
$SaveService | Export-Csv -LiteralPath $ServiceSavePath -encoding "unicode" -force -Delimiter ","
If($SavePath -ne $null){ [Windows.Forms.MessageBox]::Show("File saved as '$SavePath'","File Saved", 'OK') }
}
Function Save_ServiceBackup {
$ServiceSavePath = $filebase + $Env:computername
$SaveService = @()
$ServiceSavePath += "-Service-Backup.csv"
If($AllService -eq $null) { $AllService = Get-Service | Select-Object Name, StartType }
ForEach($Service In $AllService) {
$ServiceName = $Service.Name
If(!($Skip_Services -Contains $ServiceName)) {
Switch("$($Service.StartType)") {
"Disabled" { $StartType = 1 ;Break }
"Manual" { $StartType = 2 ;Break }
"Automatic" { $exists = (Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\$ServiceName\").DelayedAutostart ;If($exists -eq 1){ $StartType = 4 } Else{ $StartType = 3 } ;Break }
Default { $StartType = "$($Service.StartType)" ;Break }
}
If($ServiceName -Like "*_*"){ $ServiceName = $ServiceName.Split('_')[0] + "?????" }
$SaveService += New-Object PSObject -Property @{ ServiceName = $ServiceName ;StartType = $StartType }
}
}
$SaveService | Export-Csv -LiteralPath $ServiceSavePath -encoding "unicode" -force -Delimiter ","
}
Function RegistryServiceFileBackup {
$SavePath = $filebase + $Env:computername
$SavePath += "-Service-Backup.reg"
If($AllService -eq $null) { $AllService = Get-Service | Select-Object Name, StartType }
Write-Output "Windows Registry Editor Version 5.00" | Out-File -Filepath $SavePath
Write-Output "" | Out-File -Filepath $SavePath -Append
ForEach($Service In $AllService) {
$ServiceName = $Service.Name
If($ServiceName -Is [system.array]){ $ServiceName = $ServiceName[0] }
Switch("$($Service.StartType)") {
"Disabled" { $ServiceTypeNum = 4 ;Break }
"Manual" { $ServiceTypeNum = 3 ;Break }
"Automatic" { $ServiceTypeNum = 2 ;Break }
}
If(!($Skip_Services -Contains $ServiceName)) {
$Num = '"Start"=dword:0000000' + $ServiceTypeNum
Write-Output "[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\$ServiceName]" | Out-File -Filepath $SavePath -Append
Write-Output "$Num" | Out-File -Filepath $SavePath -Append
If($ServiceTypeNum -eq 2) {
$exists = (Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\$ServiceName\").DelayedAutostart
If($exists -eq 1){ Write-Output '"DelayedAutostart"=dword:00000001' | Out-File -Filepath $SavePath -Append }
}
Write-Output "" | Out-File -Filepath $SavePath -Append
}
}
}
Function ServiceSet([String]$BVService) {
Clear-Host
If(!($CurrServices)){ $Script:CurrServices = Get-Service | Select-Object DisplayName, Name, StartType }
$NetTCP = @("NetMsmqActivator","NetPipeActivator","NetTcpActivator")
If($LogBeforeAfter -eq 2) { DiagnosticCheck 1 }
ServiceBAfun "Services-Before"
#$csv = $csv | Where-Object { $_.ServiceName -ne "xbgm" }
If($DryRun -ne 1){ DisplayOut "Changing Service Please wait..." 14 0 } Else{ DisplayOut "List of Service that would be changed on Non-Dryrun..." 14 0 }
DisplayOut "Service_Name - Current -> Change_To" 14 0
DisplayOut "-------------------------------------" 14 0
ForEach($item In $csv) {
$ServiceTypeNum = $($item.$BVService)
$ServiceName = $($item.ServiceName)
$ServiceCommName = ($CurrServices.Where{$_.Name -eq $ServiceName}).DisplayName
If($ServiceTypeNum -eq 0 -And $ShowSkipped -eq 1) {
If($ServiceCommName -ne $null){ $DispTemp = "Skipping $ServiceCommName ($ServiceName)" } Else{ $DispTemp = "Skipping $ServiceName" }
DisplayOut $DispTemp 14 0
} ElseIf($ServiceTypeNum -ne 0) {
If($ServiceName -Like "*_*"){ $ServiceName = $ServiceName.Split('_')[0] + "_$ServiceEnd" }
$ServiceType = $ServicesTypeList[$ServiceTypeNum]
$ServiceCurrType = ServiceCheck $ServiceName $ServiceType
If($ServiceName -Is [system.array]){ $ServiceName = $ServiceName[0] }
If($ServiceCurrType -eq "Xbox") {
$DispTemp = "$ServiceCommName ($ServiceName) is an Xbox Service and will be skipped"
DisplayOut $DispTemp 2 0
} ElseIf($ServiceCurrType -ne $False -And $ServiceCurrType -ne "Already") {
$DispTemp = "$ServiceCommName ($ServiceName) - $ServiceCurrType -> $ServiceType"
If($ServiceTypeNum -In 1..4 -And $DryRun -ne 1){ Set-Service $ServiceName -StartupType $ServiceType }
If($ServiceTypeNum -eq 4) {
$DispTemp += " (Delayed Start)"
If($DryRun -ne 1){ Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Services\$ServiceName\" -Name "DelayedAutostart" -Type DWord -Value 1 }
}
DisplayOut $DispTemp 11 0
} ElseIf($ServiceCurrType -eq "Already" -And $ShowAlreadySet -eq 1) {
$DispTemp = "$ServiceCommName ($ServiceName) is already $ServiceType"
If($ServiceTypeNum -eq 4){ $DispTemp += " (Delayed Start)" }
DisplayOut $DispTemp 15 0
} ElseIf($ServiceCurrType -eq $False -And $ShowNonInstalled -eq 1) {
$DispTemp = "No service with name $ServiceName"
DisplayOut $DispTemp 13 0
}
}
}
DisplayOut "-------------------------------------" 14 0
If($DryRun -ne 1){ DisplayOut "Service Changed..." 14 0 ;ThanksDonate } Else{ DisplayOut "List of Service Done..." 14 0 }
If($BackupServiceConfig -eq 1){
If($BackupServiceType -eq 1){ DisplayOut "Backup of Services Saved as CSV file in script directory." 14 0 }
ElseIf($BackupServiceType -eq 0){ DisplayOut "Backup of Services Saved as REG file in script directory." 14 0 }
ElseIf($BackupServiceType -eq 2){ DisplayOut "Backup of Services Saved as CSV and REG file in script directory." 14 0 }
}
ServiceBAfun "Services-After"
AutomatedExitCheck 1
}
Function RegistryServiceFile([String]$TempFP) {
$ServiceCBList = $WPF_dataGrid.Items.Where({$_.checkboxChecked -eq $true})
Write-Output "Windows Registry Editor Version 5.00" | Out-File -Filepath $TempFP
Write-Output "" | Out-File -Filepath $TempFP -Append
ForEach($item In $ServiceCBList) {
$ServiceTypeNum = $item.StartType
$ServiceName = $item.ServiceName
If($ServiceTypeNum -ne 0) {
If($ServiceName -Like "*_*"){ $ServiceName = $ServiceName.Split('_')[0] + "_$ServiceEnd" }
If($ServiceName -Is [system.array]){ $ServiceName = $ServiceName[0] }
If(!($ServiceCurrType -eq "Xbox")) {
$Num = '"Start"=dword:0000000' + $ServicesRegTypeList[$ServiceTypeNum]
Write-Output "[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\$ServiceName]" | Out-File -Filepath $TempFP -Append
Write-Output "$Num" | Out-File -Filepath $TempFP -Append
If($ServiceTypeNum -eq 4) { Write-Output '"DelayedAutostart"=dword:00000001' | Out-File -Filepath $TempFP -Append }
Write-Output "" | Out-File -Filepath $TempFP -Append
}
}
}
[Windows.Forms.MessageBox]::Show("Registry File saved as '$TempFP'","File Saved", 'OK')
}
Function ServiceCheck([String]$S_Name,[String]$S_Type) {
If($CurrServices.Name -Contains $S_Name) {
If($XboxService -eq 1 -and $XboxServiceArr -Contains $S_Name) { Return "Xbox" }
$C_Type = ($CurrServices.Where{$_.Name -eq $S_Name}).StartType