forked from Legend0fHell/SPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSPI.cmd
More file actions
1989 lines (1833 loc) · 85.5 KB
/
Copy pathSPI.cmd
File metadata and controls
1989 lines (1833 loc) · 85.5 KB
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
:: =====================================================================================
::
:: Restart Internet Connection - Fix Internet Connection [SPI]
:: Introductory Header
::
:: FILE: SPI.cmd
::
:: DESCRIPTION: SPI is a script that restart the connection, and also optimizes
:: your connection by lots of verified methods.
::
:: USAGE: One-press optimization.
:: Open by the given shortcut.
::
:: REQUIREMENTS: Windows 7 or newer.
:: Services related to Internet connection must be turned on.
::
:: AUTHOR: Pham Nhat Quang [Legend0fHell]
:: VERSION: 4.3.0
:: CREATED: 06.08.2016 - 15:29:37
:: REVISION: 19.06.2020
::
:: =====================================================================================
::
:: Notes
::
:: This script is not contain any malicious codes/viruses. All the modules were commented.
:: To improve the optimize speed, this script will use multi-tasking, meaning that there will be several instances running all at once.
:: Debugging is always harder than programming, so if you write code as cleverly as you know how, by definition you will be unable to debug it.
::
:: =====================================================================================
::
:: Changelog
::
:: Version 4.3.0 [04.06.2020]
:: * ADD:
:: - Easier way to check the latency.
:: - Shortcut Generator.
:: - Proper Icon file.
:: * CHANGES:
:: - GUI Header.
::
:: =====================================================================================
:: Set console.
:: /************************************************************************************/
:main.mode
@echo off
CHCP 1258 >nul 2>&1
CHCP 65001 >nul 2>&1
setlocal EnableExtensions EnableDelayedExpansion
set ver=4.3.0
set verdate=Jun 19 2020
set configLineSkip=61
color 0e
:: /************************************************************************************/
:: Set the default config.
:: /************************************************************************************/
:config.default
set width=90
set height=35
set lang=2
set colorPrompt=E
set colorWorking=A
set autoChoose=30
set checkPingEnable=1
set pingURL=facebook.com
set dns1=1.1.1.1
set dns2=1.0.0.1
set promptUseEnable=1
set customHosts=0
set operateMode=0
set browsersFound=0
set connectionStatusLength=0
set PingLength=0
set end=10
:: /************************************************************************************/
:: Check if the config files is valid.
:: /************************************************************************************/
:config.checkVaild
:: Create a referrence version file to validate the config file.
(
echo # Setting the config wrong can cause the script to crash. Do not change configVersion.
echo # If the script crash, try deleting this config file.
echo configVersion=!ver!-!verdate!
) >"%temp%\ver.txt"
set configDir=%~dp0config.txt
:: Check the existance of the config file. Compare with the referrence file.
:: If the config file is found and valid go to set the config else recreate it.
if exist !configDir! (
set existConfig=1
echo N | comp /n=3 "!temp!\ver.txt" "!configDir!" | findstr /i "OK" && call :config.set
) else (
set existConfig=0
)
call :config.update
call :main.setVariables
goto main.checkVer
:: /************************************************************************************/
:: Set the variables needed.
:: /************************************************************************************/
:main.setVariables
mode con cols=!width! lines=!height!
title SPI ^| Restart Internet Connection - Fix Internet Connection
set "valuecore="
set "core="
set "linesCore= "
for /l %%G in (!width!,-1,1) do (
set valuecore=!valuecore!
set core=!core!=
)
for /l %%G in (!width!,-1,3) do (
set linesCore=!linesCore!_
)
set space=!valuecore!
set widthTemp=!width!
set label=Starting&call :main.label 8
set internetStatus=1
set now=-1
set /a length=!end! * (!width! / (!end!+2))
set /a left=(!width!-!length!)/2-1
set /a between=!width!-8-(!left!*2)
set /a endprog=10000/!end!
set /a char=!length!/!end!
set counter=0
set counterb=000
set noPhaseChanged=0
set failedPingCheck=0
set showInfo=0
set retryTime=0
goto :EOF
:: /************************************************************************************/
:: Check the OS version.
:: /************************************************************************************/
:main.checkVer
ver | findstr /i "6\.1\." > nul
if %ERRORLEVEL% EQU 0 (
set ChOS=Windows 7
set OSAllowed=1
)
ver | findstr /i "6\.2\." > nul
if %ERRORLEVEL% EQU 0 (
set ChOS=Windows 8
set OSAllowed=1
)
ver | findstr /i "6\.3\." > nul
if %ERRORLEVEL% EQU 0 (
set ChOS=Windows 8.1
set OSAllowed=1
)
ver | findstr /i "10\.0\." > nul
if %ERRORLEVEL% EQU 0 (
set ChOS=Windows 10
set OSAllowed=1
)
if %OSAllowed% NEQ 1 (
cls
set label=Failed&call :main.label 6
echo You MUST use Windows 7 or newer versions so that the script can work properly.
echo Supported System: Windows 7, 8, 8.1, 10. Windows Server is NOT RECOMMENDED.
echo Press any key to exit.
echo.
set label=That bai&call :main.label 8
echo Ban PHAI sử dụng Windows 7 hoac phien ban moi hon đe su dung dung cu.
echo Ho tro: Windows 7, 8, 8.1, 10. KHONG KHUYEN NGHI su dung Windows Server.
echo Nhan phim bat ky de thoat.
pause >nul
exit
)
:: /************************************************************************************/
:: Check if users run the Script via the given Shortcut.
:: /************************************************************************************/
:main.checkShortcut
:: Find the argument "1" when opening the file. This is to check if the script was run by the given shortcut.
echo %1 | findstr "1" >nul
if %errorlevel%==1 (
if %lang%==2 del /f /s config.txt >nul
cls
set label=Failed&call :main.label 6
echo You MUST run this Script via the given Shortcut in order for it to work.
echo Press any key to exit.
echo.
set label=That bai&call :main.label 8
echo Ban PHAI chay cong cu nay bang Loi tat ^(Shortcut^) da cho de cong cu hoat dong.
echo Nhan phim bat ky de thoat.
pause >nul
exit
)
:: Checking things.
call :main.preloadPS
if %lang%==1 (echo [%time%] Đang chạy trước PowerShell...) else (echo [%time%] Preloading PowerShell...)
if %lang%==1 (echo [%time%] Đang kiểm tra kết nối mạng...) else (echo [%time%] Checking the Internet connection...)
call :main.checkConnection 1
if %lang%==1 (echo [%time%] Đang kiểm tra trình duyệt...) else (echo [%time%] Checking the browsers...)
call :main.checkBrowsers
set connectionStatusLengthBackup=!connectionStatusLength!
set failedPingCheckBackup=!failedPingCheck!
goto config.detectFirstRun
:: /************************************************************************************/
:: Set the custom config.
:: /************************************************************************************/
:config.set
for /f delims^=^ eol^=# %%i in ('findstr "=" config.txt') do (set "%%i") >nul
if %customHosts%==1 (
del /f /q %temp%\customHosts.txt >nul
for /f "delims= skip=%configLineSkip%" %%i in (config.txt) do (
echo %%i>>"%temp%\customHosts.txt"
)
)
goto :EOF
:: /************************************************************************************/
:: Update the config with new settings or restart it.
:: /************************************************************************************/
:config.update
if !existConfig!==1 call :config.set
(
echo # Setting the config wrong can cause the script to crash. Do not change configVersion.
echo # If the script crash, try deleting this config file.
echo configVersion=!ver!-!verdate!
echo.
echo [Script Settings]
echo # Change the Width of the Console. [Default: 90 - For the best appearance] [Min: 80] [Character]
echo width=!width!
echo.
echo # Change the Height of the Console. [Default: 35] [Min: 35] [Character]
echo height=!height!
echo.
echo # Auto-Select or Prompt the Languages. [Default: Ask] [0-English / 1-Vietnamese / 2-Ask]
echo lang=!lang!
echo.
echo # Change the Prompt Color. See Color Table for details. [Default: E] [1-9 / A-F]
echo colorPrompt=!colorPrompt!
echo.
echo # Change the Working Color. See Color Table for details. [Default: A] [1-9 / A-F]
echo colorWorking=!colorWorking!
echo.
echo [Color Table]
echo.
echo # ColorCode ColorName ColorCode ColorName
echo # --------- ------------ --------- ------------
echo # 1 Blue 9 Light Blue
echo # 2 Green A Light Green
echo # 3 Aqua B Light Aqua
echo # 4 Red C Light Red
echo # 5 Purple D Light Purple
echo # 6 Yellow E Light Yellow
echo # 7 White F Bright White
echo # 8 Gray
echo.
echo [Progress Settings]
echo.
echo # Change the auto-choose interval. [Default: 30] [0-9999] [Seconds]
echo autoChoose=!autoChoose!
echo.
echo # Enable or Disable the Latency Checking. [Default: 1] [0-Disable / 1-Enable]
echo checkPingEnable=!checkPingEnable!
echo.
echo # Change the URL to Check the Latency. [Default: facebook.com] [Valid URL] [URL/IP]
echo pingURL=!pingURL!
echo.
echo # Change the DNS that the script will use. There are 2 addresses, Primary[1] and Secondary[2] DNS.
echo # [Default: 1.1.1.1 / 1.0.0.1 - CloudFlare] [Vaild DNS] [IPv4]
echo dns1=!dns1!
echo dns2=!dns2!
echo.
echo # Prompt to use the Script. [Default: 1] [0-Disable / 1-Enable]
echo promptUseEnable=!promptUseEnable!
echo.
echo [Hosts File Settings]
echo.
echo # Allow your custom addresses to be added to your Hosts file. [Default: 0] [0-Permit / 1-Allow]
echo customHosts=!customHosts!
echo.
echo # These addresses will be added to your Hosts file to stop Telemetry.
echo # To add your custom addresses, you must allow customHosts by the above settings.
echo.
) >config.txt
:: Set the default addresses in the config file. If customHosts is 1, it will skip setting the default addresses.
if %customHosts%==1 (
type %temp%\customHosts.txt >>config.txt
) else (
(
echo 184-86-53-99.deploy.static.akamaitechnologies.com
echo a-0001.a-msedge.net
echo a-0002.a-msedge.net
echo a-0003.a-msedge.net
echo a-0004.a-msedge.net
echo a-0005.a-msedge.net
echo a-0006.a-msedge.net
echo a-0007.a-msedge.net
echo a-0008.a-msedge.net
echo a-0009.a-msedge.net
echo a1621.g.akamai.net
echo a1856.g2.akamai.net
echo a1961.g.akamai.net
echo a248.e.akamai.net
echo a978.i6g1.akamai.net
echo a.ads1.msn.com
echo a.ads2.msads.net
echo a.ads2.msn.com
echo ac3.msn.com
echo ad.doubleclick.net
echo adnexus.net
echo adnxs.com
echo ads1.msads.net
echo ads1.msn.com
echo ads.msn.com
echo aidps.atdmt.com
echo aka-cdn-ns.adtech.de
echo a-msedge.net
echo any.edge.bing.com
echo a.rad.msn.com
echo az361816.vo.msecnd.net
echo az512334.vo.msecnd.net
echo b.ads1.msn.com
echo b.ads2.msads.net
echo bingads.microsoft.com
echo b.rad.msn.com
echo bs.serving-sys.com
echo c.atdmt.com
echo cdn.atdmt.com
echo cds26.ams9.msecn.net
echo choice.microsoft.com
echo choice.microsoft.com.nsatc.net
echo compatexchange.cloudapp.net
echo corpext.msitadfs.glbdns2.microsoft.com
echo corp.sts.microsoft.com
echo cs1.wpc.v0cdn.net
echo db3aqu.atdmt.com
echo df.telemetry.microsoft.com
echo diagnostics.support.microsoft.com
echo e2835.dspb.akamaiedge.net
echo e7341.g.akamaiedge.net
echo e7502.ce.akamaiedge.net
echo e8218.ce.akamaiedge.net
echo ec.atdmt.com
echo fe2.update.microsoft.com.akadns.net
echo feedback.microsoft-hohm.com
echo feedback.search.microsoft.com
echo feedback.windows.com
echo flex.msn.com
echo g.msn.com
echo h1.msn.com
echo h2.msn.com
echo hostedocsp.globalsign.com
echo i1.services.social.microsoft.com
echo i1.services.social.microsoft.com.nsatc.net
echo ipv6.msftncsi.com
echo ipv6.msftncsi.com.edgesuite.net
echo lb1.www.ms.akadns.net
echo live.rads.msn.com
echo m.adnxs.com
echo msedge.net
echo msftncsi.com
echo msnbot-65-55-108-23.search.msn.com
echo msntest.serving-sys.com
echo oca.telemetry.microsoft.com
echo oca.telemetry.microsoft.com.nsatc.net
echo onesettings-db5.metron.live.nsatc.net
echo pre.footprintpredict.com
echo preview.msn.com
echo rad.live.com
echo rad.msn.com
echo redir.metaservices.microsoft.com
echo reports.wes.df.telemetry.microsoft.com
echo schemas.microsoft.akadns.net
echo secure.adnxs.com
echo secure.flashtalking.com
echo services.wes.df.telemetry.microsoft.com
echo settings-sandbox.data.microsoft.com
echo settings-win.data.microsoft.com
echo sls.update.microsoft.com.akadns.net
echo sqm.df.telemetry.microsoft.com
echo sqm.telemetry.microsoft.com
echo sqm.telemetry.microsoft.com.nsatc.net
echo ssw.live.com
echo static.2mdn.net
echo statsfe1.ws.microsoft.com
echo statsfe2.update.microsoft.com.akadns.net
echo statsfe2.ws.microsoft.com
echo survey.watson.microsoft.com
echo telecommand.telemetry.microsoft.com
echo telecommand.telemetry.microsoft.com.nsatc.net
echo telemetry.appex.bing.net
echo telemetry.microsoft.com
echo telemetry.urs.microsoft.com
echo vortex-bn2.metron.live.com.nsatc.net
echo vortex-cy2.metron.live.com.nsatc.net
echo vortex.data.microsoft.com
echo vortex-sandbox.data.microsoft.com
echo vortex-win.data.microsoft.com
echo cy2.vortex.data.microsoft.com.akadns.net
echo watson.live.com
echo watson.microsoft.com
echo watson.ppe.telemetry.microsoft.com
echo watson.telemetry.microsoft.com
echo watson.telemetry.microsoft.com.nsatc.net
echo wes.df.telemetry.microsoft.com
echo win10.ipv6.microsoft.com
echo www.bingads.microsoft.com
echo www.go.microsoft.akadns.net
echo www.msftncsi.com
echo client.wns.windows.com
echo wdcpalt.microsoft.com
echo settings-ssl.xboxlive.com
echo settings-ssl.xboxlive.com-c.edgekey.net
echo settings-ssl.xboxlive.com-c.edgekey.net.globalredir.akadns.net
echo e87.dspb.akamaidege.net
echo insiderservice.microsoft.com
echo insiderservice.trafficmanager.net
echo e3843.g.akamaiedge.net
echo flightingserviceweurope.cloudapp.net
echo static.ads-twitter.com
echo www-google-analytics.l.google.com
echo p.static.ads-twitter.com
echo hubspot.net.edge.net
echo e9483.a.akamaiedge.net
echo www.google-analytics.com
echo padgead2.googlesyndication.com
echo mirror1.malwaredomains.com
echo mirror.cedia.org.ec
echo hubspot.net.edgekey.net
echo insiderppe.cloudapp.net
echo livetileedge.dsx.mp.microsoft.com
echo fe2.update.microsoft.com.akadns.net
echo s0.2mdn.net
echo statsfe2.update.microsoft.com.akadns.net
echo survey.watson.microsoft.com
echo view.atdmt.com
echo watson.microsoft.com
echo watson.ppe.telemetry.microsoft.com
echo watson.telemetry.microsoft.com
echo watson.telemetry.microsoft.com.nsatc.net
echo wes.df.telemetry.microsoft.com
echo apps.skype.com
echo c.msn.com
echo pricelist.skype.com
echo s.gateway.messenger.live.com
echo ui.skype.com
) >>config.txt
)
if !existConfig! NEQ 2 call :config.set
goto :EOF
:: /************************************************************************************/
:: Ask the users the language they are going to use.
:: /************************************************************************************/
:config.languageSelect
cls
set label=Select Language&call :main.label 15
echo 1/ If something went wrong (the script automatically runs, etc. ),
echo close this windows, delete "config.txt" in this folder and run this
echo script via the given Shortcut.
echo 2/ You can create a Shortcut via the option in Additional Tools.
echo 3/ Make sure this script's directory DOES NOT CONTAIN any Unicode characters:
echo %~dp0
echo 4/ Automatically choose English in !autoChoose! second[s].
echo.
set label=Chọn Ngôn ngữ&call :main.label 13
echo 1/ Nếu xảy ra lỗi (công cụ tự động chạy,...), tắt cửa sổ này, xóa "config.txt"
echo trong thư mục này và mở công cụ bằng Lối dẫn (Shortcut) đã cho.
echo 2/ Bạn có thể tạo Lối dẫn (Shortcut) bằng lựa chọn trong mục Công cụ Bổ sung.
echo 3/ Đảm bảo đường dẫn của công cụ KHÔNG CHỨA những ký tự Unicode (chữ Việt,...)
echo %~dp0
echo 4/ Tự động chọn Tiếng Anh sau !autoChoose! giây.
set /a blankLines=!height!-20
call :main.blankLines !blankLines!
echo !linesCore!
echo Press the corresponding key of the language. ^| Nhấn phím thích hợp của ngôn ngữ.
choice /c ve /n /t !autoChoose! /d e /m " [E] English [V] Tiếng Việt"
set /a lang-=%errorlevel%
set existConfig=2
call :config.update
goto main.setGUI
:: /************************************************************************************/
:: Check the connection.
:: /************************************************************************************/
:main.checkConnection
:: Mode 0 = Checking just for connection.
:: Mode 1 = Checking the connection and the latency.
ping -n 1 !dns1! | findstr TTL >nul && set "internetStatus=1" || set internetStatus=0
if %1 == 1 (
if %checkPingEnable%==1 (
call :progress.checkLatency1
if !failedPingCheck! == 1 (
if !lang! == 0 (
if !internetStatus! == 0 (
set connectionStatus=No connection found.
set connectionStatusLength=20
) else (
set connectionStatus=Connection timed out.
set connectionStatusLength=21
)
) else (
if !internetStatus! == 0 (
set connectionStatus=Không có kết nối.
set connectionStatusLength=17
) else (
set connectionStatus=Quá thời gian kết nối.
set connectionStatusLength=22
)
)
) else (
set PingBefore2=!PingBefore!
call :sub.findPingLength
set /a connectionStatusLength=!PingLength!+2
set connectionStatus=!PingBefore!ms
)
) else (
if !lang! == 0 (
set connectionStatus=Feature disabled.
set connectionStatusLength=17
) else (
set connectionStatus=Tính năng bị vô hiệu hóa.
set connectionStatusLength=25
)
)
)
goto :EOF
:: /************************************************************************************/
:: Find the length of the latency.
:: /************************************************************************************/
:sub.findPingLength
if !pingBefore2!==0 (
goto :EOF
) else (
set /a PingLength+=1
set /a PingBefore2=!PingBefore2!/10
goto sub.findPingLength
)
:: /************************************************************************************/
:: Preload PowerShell.
:: /************************************************************************************/
:main.preloadPS
start "SPI | Preload PowerShell" /MIN cmd /c powershell -Command "& {exit;}"
goto :EOF
:: /************************************************************************************/
:: Check the appearance of browsers. If the script detects them, it will prompt the users.
:: /************************************************************************************/
:main.checkBrowsers
FOR /F %%x IN ('tasklist /NH /FI "IMAGENAME eq chrome.exe"') DO IF %%x == chrome.exe set browsersFound=1
FOR /F %%x IN ('tasklist /NH /FI "IMAGENAME eq firefox.exe"') DO IF %%x == firefox.exe set browsersFound=1
FOR /F %%x IN ('tasklist /NH /FI "IMAGENAME eq opera.exe"') DO IF %%x == opera.exe set browsersFound=1
FOR /F %%x IN ('tasklist /NH /FI "IMAGENAME eq msedge.exe"') DO IF %%x == msedge.exe set browsersFound=1
FOR /F %%x IN ('tasklist /NH /FI "IMAGENAME eq vivaldi.exe"') DO IF %%x == vivaldi.exe set browsersFound=1
FOR /F %%x IN ('tasklist /NH /FI "IMAGENAME eq thunderbird.exe"') DO IF %%x == thunderbird.exe set browsersFound=1
goto :EOF
:: /************************************************************************************/
:: Backup files before the script changes anything.
:: /************************************************************************************/
:main.backup
:: Create Backup Info File.
(
echo # This is the directory that SPI made to store the backup.
echo # Backup created at !time! !date!
echo backupCreateTime=!time! !date!
) > "backup\backupInfo.txt"
:: Backup Hosts file.
copy "%WINDIR%\system32\drivers\etc\hosts" "backup\hosts"
:: Reading the ipconfig setting
for /f "tokens=* delims={}" %%i in ('wmic nicconfig get DNSServerSearchOrder ^| findstr "{"') do (
set backupDNSOutput=%%i
(echo backup_DNS=!backupDNSOutput:}=!) >> "backup\backupFile"
)
goto :EOF
:: /************************************************************************************/
:: Check if this is the first time the script is opened on the users' PC.
:: /************************************************************************************/
:config.detectFirstRun
if %lang%==2 goto config.languageSelect
goto main.setGUI
:: /************************************************************************************/
:: Calculate the execution time of an activity.
:: /************************************************************************************/
:main.timer
set options="tokens=1-4 delims=:.,"
for /f %options% %%a in ("%timerStart%") do set timerStart_h=%%a&set /a timerStart_m=100%%b %% 100&set /a timerStart_s=100%%c %% 100&set /a timerStart_ms=100%%d %% 100
for /f %options% %%a in ("%timerEnd%") do set timerEnd_h=%%a&set /a timerEnd_m=100%%b %% 100&set /a timerEnd_s=100%%c %% 100&set /a timerEnd_ms=100%%d %% 100
set /a hours=%timerEnd_h%-%timerStart_h%
set /a mins=%timerEnd_m%-%timerStart_m%
set /a secs=%timerEnd_s%-%timerStart_s%
set /a ms=%timerEnd_ms%-%timerStart_ms%
if %ms% lss 0 set /a secs-=1 & set /a ms = 100%ms%
if %secs% lss 0 set /a mins-=1 & set /a secs = 60%secs%
if %mins% lss 0 set /a hours-=1 & set /a mins = 60%mins%
if %hours% lss 0 set /a hours = 24%hours%
if 1%ms% lss 100 set ms=0%ms%
set /a totalsecs = %hours%*3600 + %mins%*60 + %secs%
goto :EOF
:: /************************************************************************************/
:: Echo the given blank lines. This is GUI-based.
:: /************************************************************************************/
:main.blankLines
for /l %%G in (1,1,%1) do echo.
goto :EOF
:: /************************************************************************************/
:: Print the labels.
:: /************************************************************************************/
:main.label
set /a leftLabel=(%widthTemp%-%1-34)/2
echo !space:~0,%leftLabel%! +============== %label% ==============+
goto :EOF
:: /************************************************************************************/
:: Print the header and title.
:: /************************************************************************************/
:main.header
cls
echo %title%
echo %subtitle%
echo %core%
goto :EOF
:: /************************************************************************************/
:: Print the progress bar and custom title.
:: /************************************************************************************/
:main.showProgress
if %noPhaseChanged%==1 (
set now=-1
set counterb=000
set valuecore=%space%
)
set color=%2
if %color%==2 (color 0%colorPrompt%) else (color 0%colorWorking%)
call :main.header
echo %progress%: !progress[%3]! - %1
set /a now+=1
if %now%==10 set /a between-=1
if %counterb% LSS 1000 (set percent= %counterb:~0,-2%) else if %counterb% LSS 10000 (set percent= %counterb:~0,-2%) else if %counterb%==10000 (set percent=%counterb:~0,-2%)
echo !space:~0,%left%![!valuecore:~0,%length%!]
echo !space:~0,%left%!%now%/%end%!space:~0,%between%!%percent%%%
title SPI ^| %counterb:~0,-2%%% %now%/%end% ^| !progress[%3]! - %1
set /a counter+=%char%
if %noPhaseChanged%==0 (
set /a counterb+=%endprog%
set valuecore=!core:~0,%counter%!%space%
)
if %noPhaseChanged%==2 (
set /a now-=1
set /a counter-=%char%
)
echo.
goto :EOF
:: /************************************************************************************/
:: Set the Internet Status Info on the title of the script.
:: /************************************************************************************/
:main.setInternetStatus
set /a alignTitle=!width!-2-27-12-!connectionStatusLength!
set title=Restart Internet Connection!space:~0,%alignTitle%!Connection: !connectionStatus!
set /a alignSubtitle=!width!-36-38
set noInternet=Please check your Internet connection.
if !lang!==1 (
set /a alignTitle=!width!-30-9-!connectionStatusLength!
set title=Khởi động lại Kết nối Internet!space:~0,%alignTitle%!Kết nối: !connectionStatus!
set /a alignSubtitle=!width!-36-30
set noInternet=Hãy kiểm tra kết nối Internet.
)
if !failedPingCheck!==0 (set subtitle=Legend0fHell - %ver% - %verdate%) else (set subtitle=Legend0fHell - %ver% - %verdate%!space:~0,%alignSubtitle%!!noInternet!)
goto :EOF
:: /************************************************************************************/
:: Set GUI elements.
:: /************************************************************************************/
:main.setGUI
title SPI ^| Restart Internet Connection - Fix Internet Connection
set optYn= [Y] Accept [N] Decline
set optYnC= [Y] Restart [O] Optimize [T] Additional Tools [I] Show Info
set optCS= [Y] Close [N] Skip
set optOC= [O] Open [C] Close
set autoAcceptMsg= Automatically choose Restart in %autoChoose% second[s].
set autoDeclineMsg= Automatically decline in %autoChoose% second[s].
set splitTitle=Multi-Task
set progress[1]=Checks
set progress[2]=TCP/IP Settings
set progress[3]=Browsers Tweaks
set progress[4]=Telemetry Settings
set progress[5]=Explorer Settings
set progress[6]=OneDrive Settings
set progress[7]=Adapters Settings
set progress[8]=Status
set progress[9]=Registry Settings
set progress=Progress
set guideMsg= Press the corresponding key of the tool.
set "titleMoreTool=SPI ^| Additional Tools"
if !lang!==1 (
title SPI ^| Khởi động lại Kết nối Internet - Sửa Kết nối Internet
set optYn= [Y] Đồng ý [N] Từ chối
set optYnC= [Y] Khởi động lại [O] Tối ưu [T] Công cụ Bổ sung [I] Hiện Thông tin
set optCS= [Y] Đóng [N] Bỏ qua
set optOC= [O] Mở [C] Đóng
set autoAcceptMsg= Tự động chọn Khởi động lại trong %autoChoose% giây.
set autoDeclineMsg= Tự động từ chối trong %autoChoose% giây.
set splitTitle=Tách
set progress[1]=Kiểm tra
set progress[2]=Cài đặt TCP/IP
set progress[3]=Cài đặt Trình duyệt
set progress[4]=Cài đặt Telemetry
set progress[5]=Cài đặt Explorer
set progress[6]=Cài đặt OneDrive
set progress[7]=Cài đặt Adapter
set progress[8]=Trạng thái
set progress[9]=Cài đặt Registry
set progress=Tiến trình
set "titleMoreTool=SPI ^| Công cụ Bổ sung"
set guideMsg= Nhấn phím thích hợp của công cụ muốn chọn.
)
call :main.setInternetStatus
if %promptUseEnable%==0 (
call :main.showProgress "Ready" 2 8
goto main.preSetting
)
:: /************************************************************************************/
:: Ask if users want to use this script and other guides.
:: /************************************************************************************/
:main.confirmUse
if !lang!==0 (
call :main.showProgress "Ready" 2 8
echo Restart Internet Connection [SPI] is a script that restarts your connection.
echo.
echo Using this will interrupt your Internet connection for a very short time.
echo THIS SCRIPT WILL NOT REVERSE CHANGES. Use this script at your OWN RISKS.
) else (
call :main.showProgress "Sẵn sàng" 2 8
echo Khởi động lại Kết nối Internet [SPI] là công cụ khởi động lại đường truyền của bạn.
echo.
echo Sử dụng công cụ này sẽ ngắt kết nối Internet của bạn trong thời gian rất ngắn.
echo CÔNG CỤ KHÔNG ĐẢO NGƯỢC NHỮNG THAY ĐỔI. Bạn CHỊU TRÁCH NHIỆM khi dùng công cụ.
)
set /a blankLines=!height!-16
:: Echo this if showInfo is 1.
if %showInfo%==1 (
echo.
if !lang!==0 (
echo This script will restart Internet connection by doing the following works:
echo + Flush DNS, release and renew IP.
echo + Delete unnecessary files.
echo + Run SpeedyFox - a safe browsers optimization tool.
echo + Restart networks adapters.
echo This script will optimize Internet connection by doing the following works:
echo + Configurate TCP/IP/DNS.
echo + Change Telemetry Settings, stop sending data to Microsoft.
echo + Uninstall OneDrive/OneNote, modify Explorer.
echo + Change Registry settings, Hosts file, and network adapters.
echo + Settings that reduce ping on many games: PUBG, CS:GO, LoL, etc.
) else (
echo Công cụ này sẽ khởi động lại kết nối Internet bằng các việc sau:
echo + Xả DNS, làm mới IP.
echo + Xóa bỏ những file thừa, file rác.
echo + Chạy SpeedyFox - công cụ tối ưu hóa trình duyệt an toàn.
echo + Khởi động lại các adapter mạng.
echo Công cụ này sẽ tối ưu tốc độ Internet bằng các việc sau:
echo + Thay đổi cài đặt TCP/IP/DNS.
echo + Thay đổi cài đặt Telemetry, chặn dữ liệu tới Microsoft.
echo + Gỡ cài đặt OneDrive/OneNote, chỉnh sửa Explorer.
echo + Thay đổi cài đặt trong Registry, file Hosts, và các adapter mạng.
echo + Các thiết đặt giảm độ trễ cho rất nhiều game: PUBG, CS:GO, LoL, v.v.
)
set /a blankLines-=12
)
call :main.blankLines !blankLines!
echo !linesCore!
echo %guideMsg% ^|%autoAcceptMsg%
choice /c ytio /n /t %autoChoose% /d y /m "%optYnC%"
if %errorlevel%==1 goto main.preSetting
if %errorlevel%==2 (
set errorMoreTool=.
goto main.moreTools
)
if %errorlevel%==3 (
if %showInfo%==0 (
set showInfo=1
if !lang! == 0 (
set optYnC= [Y] Restart [O] Optimize [T] Additional Tools [I] Hide Info
) else (
set optYnC= [Y] Khởi động lại [O] Tối ưu [T] Công cụ Bổ sung [I] Ẩn Thông tin
)
) else (
set showInfo=0
if !lang! == 0 (
set optYnC= [Y] Restart [O] Optimize [T] Additional Tools [I] Show Info
) else (
set optYnC= [Y] Khởi động lại [O] Tối ưu [T] Công cụ Bổ sung [I] Hiện Thông tin
)
)
set noPhaseChanged=1
goto main.confirmUse
)
if %errorlevel%==4 (
set operateMode=1
goto main.preSetting
)
:: /************************************************************************************/
:: Contain additional Batch tools related to Internet connection.
:: /************************************************************************************/
:main.moreTools
IF not exist output\ mkdir output
cls
call :main.header
title %titleMoreTool%
set /a blankLines=!height!-34
if !lang!==0 (
set label=Additional Tools&call :main.label 16
echo.
echo Additional Batch Tools
echo -----------------------
echo [1] Show your Public IP, Private IP and MAC Address.
echo [2] Trace the Location of a Website or an IP.
echo [3] Show Your Saved Wi-Fi Passwords.
echo [4] Show Your Firewall Rules.
echo [5] Show All Active/Used IP Addresses on Your Network.
echo.
echo Shortcut
echo -----------------------
echo [6] Ping to a Website or an IP.
echo [7] Open Tracert.
echo [8] Open PathPing.
echo [9] Open "Network Connection" Window.
echo [10] Open NetStat.
echo.
echo Script-Related
echo -----------------------
echo [11] Chuyển sang Giao diện Tiếng Việt.
echo [12] Reset the Configurations to Default state.
echo [13] Generate a Shortcut to the Desktop.
echo [14] Restart the Script.
echo [15] Exit this Page.
echo!errorMoreTool!
call :main.blankLines !blankLines!
echo !linesCore!
echo Enter the corresponding number of the tool you want to use.
) else (
set label=Công cụ Bổ sung&call :main.label 15
echo.
echo Công cụ Batch Bổ sung
echo -----------------------
echo [1] Hiện IP Công cộng, IP Riêng tư và Địa chỉ MAC.
echo [2] Tìm Vị trí của một Website hoặc một IP.
echo [3] Hiện Mật khẩu Wi-Fi đã lưu.
echo [4] Hiện Thiết đặt Tường lửa.
echo [5] Hiện Tất cả IP Hoạt động/Đã dùng trong Hệ thống Mạng của bạn.
echo.
echo Phím tắt
echo -----------------------
echo [6] Ping đến một Website hoặc một IP.
echo [7] Mở Tracert.
echo [8] Mở PathPing.
echo [9] Mở Cửa sổ "Network Connection".
echo [10] Mở NetStat.
echo.
echo Liên quan tới Công cụ
echo -----------------------
echo [11] Switch to English Interface.
echo [12] Khôi phục Cài đặt Gốc.
echo [13] Tạo một Lối dẫn tới Desktop.
echo [14] Khởi động lại Công cụ.
echo [15] Thoát khỏi Trang này.
echo!errorMoreTool!
call :main.blankLines !blankLines!
echo !linesCore!
echo Nhấn số thích hợp ở công cụ bạn muốn sử dụng.
)
set /p "addOpt= [1-15]: "
cls
call :main.header
if !lang!==0 (
title %titleMoreTool% ^| Selected Tool: !addOpt!.
echo Selected tool: !addOpt!.
echo Running tool... This will take a while.
) else (
title %titleMoreTool% ^| Đã chọn Công cụ: !addOpt!.
echo Đã chọn công cụ: !addOpt!.
echo Đang chạy công cụ... Điều này sẽ mất một khoảng thời gian.
)
echo.
setlocal EnableDelayedExpansion
if !addOpt!==1 (
if !lang!==0 (echo Estimated Time: ~15 seconds.) else (echo Thời gian dự tính: ~15 giây.)
echo.
set timerStart=!time!
:: Find the Public IP by nslookup the following site.
for /f "skip=1 tokens=2 delims=: " %%G in ('nslookup myip.opendns.com. resolver1.opendns.com ^| findstr /C:"Address"') do (
set PubIP=%%G
)
for /f "delims=[] tokens=2" %%a in ('ping -4 -n 1 %ComputerName% ^| findstr [') do (
set PriIP=%%a
)
set timerEnd=!time!
call :main.timer
if !lang!==0 (
echo Your MAC Address Information:
getmac
echo.
echo Your Current Public IP: !PubIP!
echo Your Current Private IP: !PriIP!
echo.
echo Success. [!totalsecs!.!ms! seconds]
) else (
echo Thông tin về địa chỉ MAC của bạn:
getmac
echo.
echo IP Công cộng của bạn: !PubIP!
echo IP Riêng tư của bạn: !PriIP!
echo.
echo Thành công. [!totalsecs!,!ms! giây]
)
) else if !addOpt!==2 (
if !lang!==0 (
set /p input= Query Website/IP:
) else (
set /p input= Website/IP cần tìm:
)
if !lang!==0 (echo Estimated Time: ~30 seconds.) else (echo Thời gian dự tính: ~30 giây.)
echo.
set timerStart=!time!
:: nslookup the given website/IP.
nslookup !input! | findstr /c:"Addresses" >nul
if %errorlevel%==0 (
for /f "tokens=2 delims= " %%G in ('nslookup !input! ^| findstr /c:"Addresses"') do (
set IP=%%G
)
) else (
for /f "skip=1 tokens=2 delims= " %%G in ('nslookup !input! ^| findstr /c:"Address"') do (
set IP=%%G
)
)
set timerEnd=!time!
call :main.timer
if !lang!==0 (
echo Success. [!totalsecs!.!ms! seconds]
echo Traced IP: !IP!
echo.
echo Location has been sent to your default browser.
) else (
echo Thành công. [!totalsecs!,!ms! giây]
echo Đã tìm được IP: !IP!
echo.
echo Vị trí đã được gửi sang trình duyệt mặc định của bạn.
)
:: Query the IP in whatsmyip.com.
start www.whatsmyip.com/ip-trace/!IP!
) else if !addOpt!==3 (
if !lang!==0 (echo Estimated Time: ~15 seconds.) else (echo Thời gian dự tính: ~15 giây.)
echo.
set timerStart=!time!
:: Execute the following command then search for Key Content.
for /f "tokens=2 delims=:" %%G in ('netsh wlan show profile') do (
for /f "tokens=* delims= " %%H in ("%%G") do (
for /f "tokens=2 delims=:" %%a in ('netsh wlan show profile "%%H" key^=clear ^| findstr /C:"Key Content"') do (
(
echo [SSID] %%G
echo -- [Pass]%%a
echo.
) >> output\savedPass.txt
)
)