脚本之家,脚本语言编程技术及教程分享平台!
分类导航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服务器之家 - 脚本之家 - bat - 纯批处理获取硬件信息的代码

纯批处理获取硬件信息的代码

2021-10-09 01:05winload bat

此程序纯批处理,且纯净绿色,也不会在生成文件中包含我的个人信息,大家不要随意修改里面的代码结构,很可能自己电脑没问题,到了别的电脑就会获取不准

先声明:我私下会不断的更新代码,只有大幅度更新才会上传到这里(目前核心代码基本完善)!

兼容XP Win7 Win8 win10

本程序特性:

1.运行环境判断,若自身被修改则自动闪退;若PE环境则提示并指引退出;若虚拟机环境则提示信息获取可能不准;若非管理员权限也会截取并提示。
2.关于硬盘、内存容量的计算方面支持 字节 KB MB GB TB PB
3.由于有些电脑多网卡、显卡、声卡,此程序只获取正在使用的相关信息
4.硬盘温度,使用时间,通电次数纯批处理实现!(原创代码,转载请注明出处!)
5.纯批处理实现系统密匙获取(通过注册表中的加密数据进行解密)
以下是最新版本,不用后翻。

更新内容:

1.解决了众多网友反应的关于网卡信息获取不准的问题,目前已基本完美
2.调整了代码结构,优化了效率和逻辑顺序(基本上等于重写了一遍)
3.解决了之前多种情况遇到的闪退,现在只要不改代码基本是不会闪退的
最后声明:电脑系统情况多样且复杂并非完美版本 ,希望大家多多测试并提供BUG截图 以后会根据大家的测试结果不断更新。
本人QQ:540044977 若要获取实时最新版可以加好友索要,欢迎志同道合的朋友前来交流。

以下是代码:

?
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
@echo off
mode con cols=82 lines=25
Setlocal EnableDelayedExpansion
call :Inspect
title 获取硬件信息 - 正在获取相关信息,请稍等...
echo !Tit!
echo .............................................................
echo.
DxDiag /t %Temp%\Dxdiag.dll
Ping www.baidu.com>nul
if %errorlevel%==0 set NetWorking=已联网
if %errorlevel%==1 set NetWorking=未联网
:DxDiag
if exist "%Temp%\Dxdiag.dll" (
    for /f "tokens=2 delims=:" %%i in ('Findstr /IC:"Operating System: " %Temp%\Dxdiag.dll') do (
        for /f "delims=(" %%j in ("%%i") do set OS=%%j
    )
    ) else (
    Goto :DxDiag
)
title 获取硬件信息 - %OS%
for /f "tokens=2 delims=:" %%i in ('Findstr /IC:"Processor: " %Temp%\Dxdiag.dll') do set CPU=%%i
for /l %%i in (256 -1 0) do if "!CPU:~%%i,1!"=="" set CPU.Len=%%i
if %CPU.Len% gtr 67 set CPU= %CPU:~0,60% ...
echo.CPU .......%CPU%
echo.
for /f "skip=2 tokens=2 delims==" %%i in ('Wmic BaseBoard get Manufacturer^,Product^,SerialNumber^,Version /value 2^>nul') do (
    set /a Row+=1
    if !Row! == 1 set Manufacturer=%%i
    if !Row! == 2 set Product=%%i
    if !Row! == 3 set SerialNumber=%%i
    if !Row! == 4 set Version=%%i
)
set Row=0
for /f "skip=2 tokens=2 delims==" %%i in ('Wmic bios get InstallableLanguages^,ReleaseDate^,SMBIOSBIOSVersion /value 2^>nul') do (
    set /a Row+=1
    if !Row! == 1 set InstallableLanguages=%%i
    if !Row! == 2 set ReleaseDate=%%i
    if !Row! == 3 set SMBIOSBIOSVersion=%%i
)
set Row=0
for /f "skip=2 tokens=2 delims==" %%i in ('Wmic Memphysical Get MaxCapacity^,MemoryDevices /Value 2^>nul') do (
    set /a Row+=1
    if !Row! == 1 set MaxCapacity=%%i
    if !Row! == 2 set MemoryDevices=%%i
)
for /f "skip=2 tokens=2 delims==" %%i in ('Wmic Csproduct get Uuid /Value 2^>nul') do set Uuid=%%i
if "%Version%"==" " set Version=无
if "%SerialNumber%"==" " set SerialNumber=无
set /a MaxCapacity=!MaxCapacity!/1048576
set MaxCapacity=!MaxCapacity! GB
set MemoryDevices=!MemoryDevices! 个
set InstallableLanguages=!InstallableLanguages! 国语言
set ReleaseDate=%ReleaseDate:~0,4% 年 %ReleaseDate:~4,2% 月 %ReleaseDate:~6,2% 日
if "%Uuid%" == "00000000-0000-0000-0000-000000000000" set Uuid=主板维修过
if /i "%Manufacturer:~0,3%" == "MSI"    set Manufacturer=微星
if /i "%Manufacturer:~0,4%" == "ASUS"    set Manufacturer=华硕
if /i "%Manufacturer:~0,4%" == "TIMI"    set Manufacturer=小米
if /i "%Manufacturer:~0,4%" == "SOYO"    set Manufacturer=梅捷
if /i "%Manufacturer:~0,4%" == "ONDA"    set Manufacturer=昂达
if /i "%Manufacturer:~0,5%" == "SUPOX"   set Manufacturer=磐正
if /i "%Manufacturer:~0,5%" == "PCASL"   set Manufacturer=翔升
if /i "%Manufacturer:~0,5%" == "INTEL"   set Manufacturer=英特尔
if /i "%Manufacturer:~0,6%" == "MAXSUN"   set Manufacturer=铭瑄
if /i "%Manufacturer:~0,6%" == "LENOVO"   set Manufacturer=联想
if /i "%Manufacturer:~0,6%" == "ASROCK"   set Manufacturer=华擎
if /i "%Manufacturer:~0,6%" == "GALAXY"   set Manufacturer=影驰
if /i "%Manufacturer:~0,7%" == "TOSHIBA"  set Manufacturer=东芝
if /i "%Manufacturer:~0,7%" == "BIOSTAR"  set Manufacturer=映泰
if /i "%Manufacturer:~0,8%" == "GIGABYTE"  set Manufacturer=技嘉
if /i "%Manufacturer:~0,8%" == "COLORFUL"  set Manufacturer=七彩虹
if /i "%Manufacturer:~0,8%" == "SAPPHIRE"  set Manufacturer=蓝宝石
if /i "%Manufacturer:~0,8%" == "MECHREVO"  set Manufacturer=机械格命
if /i "%Manufacturer:~0,10%" == "SUPERMICRO" set Manufacturer=超微
echo.主板 ....... %Manufacturer%  %Product%
echo.
for /f "tokens=2 delims==" %%i in ('Wmic Path Win32_PhysicalMemory Get BankLabel /value 2^>nul') do set /a MemoryQuantity+=1
set MemorySize=0
for /f "tokens=3 delims=:" %%i in ('Find /c /v "" %0') do set /a H.Size=%%i
for /f "tokens=2 delims==" %%i in ('Wmic Path Win32_PhysicalMemory Get Capacity /value 2^>nul') do (
    set Capacity=%%i
    call :Addition !Capacity! !MemorySize! MemorySize
)
call :GetSize !MemorySize! MemorySize
if not !H.Size!==1069 Goto :Eof
if "!MemorySize:~-5,3!"==".00" set MemorySize=!MemorySize:~0,-5! !MemorySize:~-2!
if "!MemorySize!"=="EB" Goto :Eof
echo.内存 ....... %MemoryQuantity% 条  %MemorySize%
echo.
for /f "tokens=2 delims==" %%i in ('Wmic DiskDrive Get Model /Value^|Find /i /v "USB"') do (
    set /a HdQuantity+=1
    if !HdQuantity! == 1 set FirstDisk=%%i
)
echo.硬盘 ....... %HdQuantity% 块  %FirstDisk% (主)
echo.
set Row=0
for /f "skip=2 tokens=2 delims==" %%i in ('Wmic Path Win32_VideoController Get Name^,AdapterRam^,DriverDate^,DriverVersion^,VideoProcessor^,MaxRefreshRate^,MinRefreshRate^,VideoProcessor^,CurrentBitsPerPixel^,CurrentRefreshRate^,CurrentHorizontalResolution^,CurrentVerticalResolution /Value 2^>nul') do (
    set /a Row+=1
    if !Row! == 1 set AdapterRAM=%%i
    if !Row! == 2 set CurrentBitsPerPixel=%%i
    if !Row! == 3 set CurrentHorizontalResolution=%%i
    if !Row! == 4 set CurrentRefreshRate=%%i
    if !Row! == 5 set CurrentVerticalResolution=%%i
    if !Row! == 6 set DriverDate=%%i
    if !Row! == 7 set DriverVersion=%%i
    if !Row! == 8 set MaxRefreshRate=%%i
    if !Row! == 9 set MinRefreshRate=%%i
    if !Row! == 10 set VideoName=%%i
    if !Row! == 11 set VideoProcessor=%%i
)
if "%CurrentBitsPerPixel%" == "" (
    set Row=0
    for /f "skip=15 tokens=2 delims==" %%i in ('Wmic Path Win32_VideoController Get Name^,AdapterRam^,DriverDate^,DriverVersion^,VideoProcessor^,MaxRefreshRate^,MinRefreshRate^,VideoProcessor^,CurrentBitsPerPixel^,CurrentRefreshRate^,CurrentHorizontalResolution^,CurrentVerticalResolution /Value 2^>nul') do (
        set /a Row+=1
        if !Row! == 1 set AdapterRAM=%%i
        if !Row! == 2 set CurrentBitsPerPixel=%%i
        if !Row! == 3 set CurrentHorizontalResolution=%%i
        if !Row! == 4 set CurrentRefreshRate=%%i
        if !Row! == 5 set CurrentVerticalResolution=%%i
        if !Row! == 6 set DriverDate=%%i
        if !Row! == 7 set DriverVersion=%%i
        if !Row! == 8 set MaxRefreshRate=%%i
        if !Row! == 9 set MinRefreshRate=%%i
        if !Row! == 10 set VideoName=%%i
        if !Row! == 11 set VideoProcessor=%%i
    )
)
if "!AdapterRAM:~0,1!" == "-" set AdapterRAM=%AdapterRAM:~1%
call :GetSize !AdapterRAM! AdapterRAM
if "!AdapterRam:~-5,3!"==".00" set AdapterRam=!AdapterRam:~0,-5! !AdapterRam:~-2!
set DriverDate=%DriverDate:~0,4% 年 %DriverDate:~4,2% 月 %DriverDate:~6,2% 日
set "Resolution=%CurrentHorizontalResolution% x %CurrentVerticalResolution% (%CurrentBitsPerPixel% bit) (%CurrentRefreshRate% Hz)"
echo.显卡 ....... %VideoName% %AdapterRAM%
echo.
set Row=0
for /f "skip=2 tokens=2 delims==" %%i in ('Wmic DesktopMonitor Get PNPDeviceID^,PixelsPerXLogicalInch /Value 2^>nul') do (
    set /a Row+=1
    if !Row! == 1 set PixelsPerXLogicalInch=%%i
    if !Row! == 2 set PNPDeviceID=%%i
)
for /f "delims=\ tokens=2" %%i in ("!PNPDeviceID!") do set DisplayName=%%i
 
if "%DisplayName%"=="" (echo.屏幕 ....... !Resolution!) else (echo.屏幕 ....... !DisplayName! !Resolution!)
echo.
set Row=0
for /f "tokens=2 delims==" %%i in ('Wmic Path Win32_CDRomDrive Get Name^,MediaLoaded /Value 2^>nul') do (
    set /a Row+=1
    if !Row! == 1 set MediaLoaded=%%i
    if !Row! == 2 set CD-ROM.Name=%%i
)
if "%CD-ROM.Name%"=="" (set CD-ROM.Name=无) else (if /i "%MediaLoaded%"=="TRUE" set "MediaLoaded=(有盘)"
if /i "%MediaLoaded%"=="FALSE" set "MediaLoaded=(空)")
echo.光驱 ....... %CD-ROM.Name% %MediaLoaded%
echo.
set Row=0
for /f "tokens=2 delims=:" %%i in ('Findstr /IC:"Description: " %Temp%\Dxdiag.dll') do (
    set /a Row+=1
    if !Row! == 1 set Description=%%i
)
echo 声卡 .......%Description% (输出)
echo.
set Row=0
for /f "skip=2 tokens=2 delims==" %%i in ('Wmic Path Win32_NetworkAdapterConfiguration WHERE "IPEnabled='TRUE'" get IPAddress^,IPSubnet^,MACAddress^,DefaultIPGateway^,Caption /value 2^>nul') do (
    set /a Row+=1
    if !Row! == 1 set NetName=%%i
    if !Row! == 2 set DefaultIPGateway=%%i
    if !Row! == 3 set IP=%%i
    if !Row! == 4 set IPSubnet=%%i
    if !Row! == 5 set MACAddress=%%i
)
if "%DefaultIPGateway%" == "" (
    set Row=0
    for /f "skip=2 tokens=2 delims==" %%i in ('Wmic Path Win32_NetworkAdapterConfiguration WHERE "DHCPEnabled='TRUE'" get IPAddress^,IPSubnet^,MACAddress^,DefaultIPGateway^,Caption /value 2^>nul') do (
        set /a Row+=1
        if !Row! == 1 set NetName=%%i
        if !Row! == 2 set DefaultIPGateway=%%i
        if !Row! == 3 set IP=%%i
        if !Row! == 4 set IPSubnet=%%i
        if !Row! == 5 set MACAddress=%%i
    )
)
if "%DefaultIPGateway%" == "" (
    set Row=0
    for /f "skip=9 tokens=2 delims==" %%i in ('Wmic Path Win32_NetworkAdapterConfiguration WHERE "DHCPEnabled='TRUE'" get IPAddress^,IPSubnet^,MACAddress^,DefaultIPGateway^,Caption /value 2^>nul') do (
        set /a Row+=1
        if !Row! == 1 set NetName=%%i
        if !Row! == 2 set DefaultIPGateway=%%i
        if !Row! == 3 set IP=%%i
        if !Row! == 4 set IPSubnet=%%i
        if !Row! == 5 set MACAddress=%%i
    )
)
if "%DefaultIPGateway%" == "" (
    set Row=0
    for /f "skip=16 tokens=2 delims==" %%i in ('Wmic Path Win32_NetworkAdapterConfiguration WHERE "DHCPEnabled='TRUE'" get IPAddress^,IPSubnet^,MACAddress^,DefaultIPGateway^,Caption /value 2^>nul') do (
        set /a Row+=1
        if !Row! == 1 set NetName=%%i
        if !Row! == 2 set DefaultIPGateway=%%i
        if !Row! == 3 set IP=%%i
        if !Row! == 4 set IPSubnet=%%i
        if !Row! == 5 set MACAddress=%%i
    )
)
if "%DefaultIPGateway%" == "" (
    set IP=未联网
    set IPSubnet=未联网
    set DefaultIPGateway=未联网
)
if "%MACAddress%" == "" set MACAddress=网卡已被禁用
for /f "tokens=2 delims=]" %%i in ("!NetName!") do set NetName=%%i
if "!NetName:~0,1!" == " " set NetName=!NetName:~1!
for /f "delims=," %%i in ("!IP!") do set IP=%%i
for /f "delims=," %%i in ("!IPSubnet!") do set IPSubnet=%%i
set IP=!IP:"=!
set IP=!IP:{=!
set IP=!IP:}=!
set IPSubnet=!IPSubnet:"=!
set IPSubnet=!IPSubnet:{=!
set IPSubnet=!IPSubnet:}=!
set DefaultIPGateway=!DefaultIPGateway:{"=!
set DefaultIPGateway=!DefaultIPGateway:"}=!
echo 网卡 ....... %NetName% (%NetWorking%)
echo.
echo.
set /p 540044977=若要生成详细的电脑配置信息文件请直接回车:
Title 获取硬件信息 - 正在生成详细信息,请稍等...
if "!Titl!" Neq "检测环境处于虚拟机中,以下信息可能不准:" Color 08
set Tim.1=%Time%
set File=%ComputerName%.Txt
Reg add "HKCU\Software\Microsoft\Notepad" /v "lfFaceName" /d "fixedsys" /f >nul 2>nul
echo %Titl%>!File!
echo ...................................................................... >>!File!
echo.>>!File!
echo.关于电脑综述信息如下:>>!File!
for /f "tokens=3" %%i in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "DigitalProductId" 2^>nul') do set DigitalProductId=%%i
if "!DigitalProductId!"=="" (
    set Key=未获取
    goto :Skip)
set Row=-1
for /l %%i in (0,2,327) do (
    set /a Row+=1
    set F=!DigitalProductId:~%%i,2!
    set /a Id!Row!=0X!F:~0,1!*16+0X!F:~1,1!
)
set /a Win10=!Id66!/6^&1
set /a Id66=(!Id66!^&0XF7)^|((!Win10!^&2)*4)
set Maps=BCDFGHJKMPQRTVWXY2346789
for /l %%i in (24 -1 0) do (
    set Current=0
    for /l %%j in (14 -1 0) do (
        set /a Current*=256
        set /a J=%%j+52
        set /a Current=Id!J!+!Current!
        set /a Id!J!=!Current!/24
        set /a Current=!Current!%%24
    )
    for /l %%k in (0,1,24) do (
        if !Current!==%%k (
        set KeyTemp=!Maps:~%%k,1!!KeyTemp!
    )
)
set Last=!Current!
)
if !Win10!==1 (
    for /l %%i in (0,1,24) do set keypart1=!KeyTemp:~1,%%i!
    set Insert=N
    for /l %%i in (1,1,24) do (
        Set L=!L!!KeyTemp:~%%i,1!
        if %%i==!Last! Set L=!L!!Insert!
    )
    Set KeyTemp=!L!
    if !Last!==0 Set KeyTemp=!Insert!!KeyTemp!
)
Set Key=!KeyTemp:~0,5!-!KeyTemp:~5,5!-!KeyTemp:~10,5!-!KeyTemp:~15,5!-!KeyTemp:~20,5!
:Skip
for /f "tokens=2 delims=:" %%i in ('Findstr /IC:"System Manufacturer:" %Temp%\Dxdiag.dll') do set PCbrand=%%i
if /i "%PCbrand:~1,2%" == "HP"    set PCbrand=惠普
if /i "%PCbrand:~1,3%" == "MSI"   set PCbrand=微星
if /i "%PCbrand:~1,4%" == "ACER"   set PCbrand=宏碁
if /i "%PCbrand:~1,4%" == "TIMI"   set PCbrand=小米
if /i "%PCbrand:~1,4%" == "DELL"   set PCbrand=戴尔
if /i "%PCbrand:~1,4%" == "ASUS"   set PCbrand=华硕
if /i "%PCbrand:~1,5%" == "HASEE"  set PCbrand=神州
if /i "%PCbrand:~1,5%" == "HAIER"  set PCbrand=海尔
if /i "%PCbrand:~1,6%" == "LENOVO"  set PCbrand=联想
if /i "%PCbrand:~1,7%" == "SAMSUNG" set PCbrand=三星
if /i "%PCbrand:~1,7%" == "TOSHIBA" set PCbrand=东芝
if /i "%PCbrand:~1,8%" == "GIGABYTE" set PCbrand=技嘉
if /i "%PCbrand:~1,8%" == "MECHREVO" set PCbrand=机械格命
for /f "tokens=2 delims=:" %%j in ('Findstr /IC:"System Model:" %Temp%\Dxdiag.dll') do (
    set PCModel=%%j
    set PCModel=!PCModel:~1!
)
for /f "tokens=2 delims=={}" %%i in ('Wmic PATH Win32_SystemEnclosure get ChassisTypes /value 2^>nul') do (
    for %%j in (3,4,6,7,15) do if %%j == %%i set PCtype=台式机
    for %%j in (8,9,10,14) do if %%j == %%i set PCtype=笔记本
    if %%i == 13 set PCtype=一体机
)
if "!PCtype!" == "" set PCtype=未知
if "!PCtype!" == "台式机" set PCbrand=%Manufacturer%
if "!PCtype!" == "台式机" set PCModel=%Product%
if "!Titl!" == "检测环境处于虚拟机中,以下信息可能不准:" set PCbrand=虚拟机&set PCModel=虚拟机
echo.>>!File!
echo.  名称 ................... : %ComputerName%>>!File!
echo.>>!File!
echo.  品牌 ................... : %PCbrand%>>!File!
echo.>>!File!
echo.  型号 ................... : %PCModel%>>!File!
echo.>>!File!
echo.  类型 ................... : %PCtype%>>!File!
echo.>>!File!
for /f "tokens=2 delims==" %%i in ('Wmic OS Get InstallDate /Value 2^>nul') do set InstallDate=%%i
set InstallDate=!InstallDate:~0,4! 年 !InstallDate:~4,2! 月 !InstallDate:~6,2! 日 !InstallDate:~8,2! 时 !InstallDate:~10,2! 分 !InstallDate:~12,2! 秒
echo.  当前用户 ............... : !UserName!>>!File!
echo.>>!File!
echo.  系统版本 ............... :!OS!>>!File!
echo.>>!File!
for /f "tokens=2 delims==" %%i in ('wmic os get Version /value') do set OSVersion=%%i
echo.  系统版本号 ............. : !OSVersion!>>!File!
echo.>>!File!
for /f "tokens=2 delims==" %%i in ('wmic os get SerialNumber /value') do set SerialNumber=%%i
echo.  系统序列号 ............. : !SerialNumber!>>!File!
echo.>>!File!
echo.  系统密匙 ............... : !Key!>>!File!
echo.>>!File!
for /f "tokens=2 delims=:" %%i in ('Findstr /IC:"DirectX Version: " %Temp%\Dxdiag.dll') do set DirectX=%%i
echo.  DirectX 版本 ........... :%DirectX%>>!File!
echo.>>!File!
for /f "tokens=2 delims==" %%i in ('Wmic OS Get LastBootUpTime /Value 2^>nul') do (
    set L=%%i
    set LastBootUpTime=!L:~0,4! 年 !L:~4,2! 月 !L:~6,2! 日 !L:~8,2! 时 !L:~10,2! 分 !L:~12,2! 秒
)
echo.  开机时间 ............... : %LastBootUpTime%>>!File!
echo.>>!File!
echo.  系统初始安装日期 ....... : %InstallDate%>>!File!
echo.>>!File!
echo.>>!File!
echo.关于 CPU 的详细信息如下:>>!File!
echo.>>!File!
echo.  名称 ........... :%CPU%>>!File!
echo.>>!File!
set Row=0
for /f "skip=2 tokens=2 delims==" %%i in ('Wmic CPU get Name^,AddressWidth^,CurrentVoltage^,ExtClock^,Family^,MaxClockSpeed^,ProcessorId^,Revision^,SocketDesignation^,Stepping /value 2^>nul') do (
    set /a Row+=1
    if !Row! == 1 set AddressWidth=%%i
    if !Row! == 2 set CurrentVoltage=%%i
    if !Row! == 3 set ExtClock=%%i
    if !Row! == 4 set Family=%%i
    if !Row! == 5 set MaxClockSpeed=%%i
    if !Row! == 6 set CpuName=%%i
    if !Row! == 7 set ProcessorId=%%i
    if !Row! == 8 set Revision=%%i
    if !Row! == 9 set SocketDesignation=%%i
    if !Row! == 10 set Stepping=%%i
)
set CurrentVoltage=%CurrentVoltage:~0,1%.%CurrentVoltage:~1%
set NumberOfProcessors=-1
for /f "tokens=2 delims==" %%i in ('Wmic path Win32_PerfFormattedData_PerfOS_Processor get PercentIdleTime /value 2^>nul') do (
    set /a NumberOfProcessors+=1
    set CpuOccupy=%%i
)
if "%NumberOfProcessors%"=="-1" for /f "delims== tokens=2" %%i in ('Wmic cpu Get NumberOfLogicalProcessors /Value 2^>nul') do set NumberOfProcessors=%%i
if "%NumberOfProcessors%"=="-1" set NumberOfProcessors=未获取
set Row=0
for /f "Skip=1" %%i in ('Wmic Path Win32_CacheMemory Get MaxCacheSize 2^>nul') do (
    set /a Row+=1
    if !Row! == 1 set One=%%i
    if !Row! == 2 set Two=%%i
    if !Row! == 3 set Three=%%i
)
set /a CpuOccupy=100-%CpuOccupy%
if "%CpuOccupy%" == ""    set CpuOccupy=.
if "%CpuOccupy%" == " "   set CpuOccupy=.
if "%One%" == ""      set One=0
if "%Two%" == ""      set Two=0
if "%Three%"==""      set Three=0
if "%One%" == " "      set One=0
if "%Two%" == " "      set Two=0
if "%Three%"==" "      set Three=0
if "%Family%" == ""     set Family=.
if "%Family%" == " "     set Family=.
if "%Revision%" == ""    set Revision=.
if "%Revision%" == " "    set Revision=.
if "%Stepping%" == ""    set Stepping=.
if "%Stepping%" == " "    set Stepping=.
if "%AddressWidth%" == ""  set AddressWidth=.
if "%AddressWidth%" == " "  set AddressWidth=.
if "%CurrentVoltage%" == "" set CurrentVoltage=.
if "%CurrentVoltage%" == " " set CurrentVoltage=.
call :Space !CpuOccupy!   12 Blank.1
call :Space !CurrentVoltage! 11 Blank.2
call :Space !Stepping!    8 Blank.3
call :Space !AddressWidth!  12 Blank.4
call :Space !Family!     8 Blank.5
echo.  核心 ........... : %NumberOfProcessors% 核心>>!File!
echo.>>!File!
echo.  主频 ........... : %MaxClockSpeed% Mhz>>!File!
echo.>>!File!
echo.  外频 ........... : %ExtClock% Mhz>>!File!
echo.>>!File!
if "!NumberOfProcessors!" neq "未获取" (
set /a Score=!NumberOfProcessors!*!MaxClockSpeed!
echo.  性能评分 ....... : !Score! 分>>!File!
echo.>>!File!
)
echo.  一级缓存 ....... : %One% Kb>>!File!
echo.>>!File!
echo.  二级缓存 ....... : %Two% Kb>>!File!
echo.>>!File!
echo.  三级缓存 ....... : %Three% Kb>>!File!
echo.>>!File!
echo.  插槽 ........... : %SocketDesignation%>>!File!
echo.>>!File!
echo.  编号 ........... : %ProcessorId%>>!File!
echo.>>!File!
echo.>>!File!
echo.  已用(%)  电压(V)  步进  位宽(位)  家族  修订版号>>!File!
echo.>>!File!
echo.  %CpuOccupy%%Blank.1%%CurrentVoltage%%Blank.2%%Stepping%%Blank.3%%AddressWidth%%Blank.4%%Family%%Blank.5%%Revision%>>!File!
echo.>>!File!
echo.>>!File!
echo.关于主板的详细信息如下:>>!File!
echo.>>!File!
echo.  品牌 ........... : %Manufacturer%>>!File!
echo.>>!File!
echo.  型号 ........... : %Product%>>!File!
echo.>>!File!
echo.  版本 ........... : %Version%>>!File!
echo.>>!File!
echo.  序列号 ......... : %SerialNumber%>>!File!
echo.>>!File!
echo.  内存插槽 ....... : %MemoryDevices%>>!File!
echo.>>!File!
echo.  内存支持 ....... : %MaxCapacity%>>!File!
echo.>>!File!
echo.  出厂日期 ....... : %ReleaseDate%>>!File!
echo.>>!File!
echo.  CPU 插槽 ....... : %SocketDesignation%>>!File!
echo.>>!File!
echo.  BIOS 版本 ...... : %SmbiosbioSversion%>>!File!
echo.>>!File!
echo.  BIOS 语言 ...... : %InstallableLanguages%>>!File!
echo.>>!File!
echo.  唯一标识 ....... : %Uuid%>>!File!
echo.>>!File!
echo.>>!File!
echo.关于内存的详细信息如下:>>!File!
echo.>>!File!
echo.  数量 ........... : %MemoryQuantity% 条>>!File!
echo.>>!File!
echo.  总容量 ......... : %MemorySize%>>!File!
echo.>>!File!
echo.>>!File!
echo.  内存   容量     频率   插槽>>!File!
echo.>>!File!
set Row=0
for /f "skip=1 delims=" %%i in ('Wmic Path Win32_PhysicalMemory Get DeviceLocator^,Capacity^,Speed') do (
    set /a Row+=1
    set i=%%i
    for /f "tokens=1,2,3" %%j in ("!i!") do (
        set MemorySize=%%j
        set DeviceLocator=%%k
        set Speed=%%l
    )
    if "!Speed!"=="" set Speed=NotGet
    call :GetSize !MemorySize! MS
    call ::Space !MS! 13  Blank.1
    call ::Space !Speed! 10 Blank.2
if not "!i:~1,1!"== "" echo.  !Row!    !MS!!Blank.1!!Speed!!Blank.2!!DeviceLocator!>>!File!
)
echo.>>!File!
echo.>>!File!
set Row=0
for /f "skip=2 tokens=2 delims==" %%i in ('Wmic path Win32_PerfFormattedData_PerfOS_Memory get AvailableBytes^,CommittedBytes^,CommitLimit /value 2^>nul') do (
    set /a Row+=1
    if !Row! == 1 set AvailableBytes=%%i
    if !Row! == 2 set CommitLimit=%%i
    if !Row! == 3 set CommittedBytes=%%i
)
if "!CommitLimit!"  neq "" call :GetSize !CommitLimit! CommitLimit
if "!AvailableBytes!" neq "" call :GetSize !AvailableBytes! Available
if "!CommittedBytes!" neq "" call :GetSize !CommittedBytes! Committed
if "!Available!" neq "" (
    echo.  已用内存 : %Committed%  可用内存 : %Available%  提交限制 : %CommitLimit%>>!File!
    echo.>>!File!
    echo.>>!File!
)
echo.关于硬盘的详细信息如下:>>!File!
echo.>>!File!
echo.  数量 ........... : %HdQuantity% 块>>!File!
echo.>>!File!
set HdSize=0
for /f "skip=1 delims=" %%i in ('Wmic DiskDrive Get Size') do (
    set Var.i=%%i
    call :Addition !Var.i! !HdSize! HdSize
)
call :GetSize !HdSize! HdSize
if "!HdSize:~-5,3!"==".00" set HdSize=!HdSize:~0,-5! !HdSize:~-2!
echo.  实际容量 .............. : !HdSize!>>!File!
echo.>>!File!
if "!Tit!"=="检测环境处于虚拟机中,以下信息可能不准:" Goto :Go
for /f "tokens=2 delims==" %%i in ('Wmic /NameSpace:\\root\wmi Path MSStorageDriver_ATAPISmartData get VendorSpecific /Value 2^>Nul') do (
    set /a DiskNuber+=1
    set Smart=%%i
    set Smart=!Smart:,= !
    if not !H.Size!==1069 Goto :Eof
    for /l %%j in (3 12 362) do (
        set Nu.1=0
        for %%k in (!Smart!) do (
            set /a Nu.1+=1
            if !Nu.1! == %%j (
                if %%k == 9 (set /a Nu.2=!Nu.1!+7
                       call :Calc !Nu.1! !Nu.2! PowerOnTimeCount)
                if %%k == 12 (set /a Nu.2=!Nu.1!+7
                        call :Calc !Nu.1! !Nu.2! StartStopCount)
                set /a Nu.3=0,Nu.4=0
                if %%k == 190 (set /a Nu.3=!Nu.1!+5
                    for %%l in (!Smart!) do (
                        set /a Nu.4+=1
                        if !Nu.4! == !Nu.3! set Temperature=%%l
                        )  
                ) else (
                    if %%k == 194 (set /a Nu.3=!Nu.1!+5
                        for %%l in (!Smart!) do (
                            set /a Nu.4+=1
                            if !Nu.4! == !Nu.3! set Temperature=%%l
                        )
                    )
                )
            )
        )
    )      
set /a Day=!PowerOnTimeCount!/24
echo.>>!File!
echo   硬盘 !DiskNuber!: >>!File!
echo.>>!File!
echo   当前硬盘温度 ..................... : !Temperature! ℃>>!File!
echo.>>!File!
echo   截至目前硬盘已启停 ..................... : !StartStopCount! 次>>!File!
echo.>>!File!
echo   截至目前硬盘已累计运行 ....................... : !PowerOnTimeCount! 小时(!Day!天)>>!File!
)
echo.>>!File!
:Go
echo.>>!File!
echo.  硬盘  分区   模式    容量    状态    型号>>!File!
echo.>>!File!
set Row=0
for /f "skip=1 delims=" %%i in ('Wmic DiskDrive Get Partitions^,InterFacetype^,Size^|Find /i /v "USB"') do (
    set /a Row+=1
    set i=%%i
    for /f "tokens=1,2,3" %%j in ("!i!") do (
        set InterfaceType=%%j
        set Partitions=%%k
        set DiskSize=%%l
    )
    set Rox=0
    for /f "skip=1 delims=" %%m in ('Wmic DiskDrive Get Caption^|Find /i /v "USB"') do (
        set /a Rox+=1
        if !Rox! == !Row! set DiskCaption=%%m
    )
    if !Row! == 1 (set Disklevel=主盘) else (set Disklevel=从盘)
    call :GetSize !DiskSize! NominalSize
    if "!NominalSize:~0,3!" == "74." set NominalSize=80GB
    if "!NominalSize:~0,3!" == "111" set NominalSize=120GB
    if "!NominalSize:~0,3!" == "119" set NominalSize=128GB
    if "!NominalSize:~0,3!" == "149" set NominalSize=160GB
    if "!NominalSize:~0,3!" == "223" set NominalSize=240GB
    if "!NominalSize:~0,3!" == "232" set NominalSize=250GB
    if "!NominalSize:~0,3!" == "238" set NominalSize=256GB
    if "!NominalSize:~0,3!" == "298" set NominalSize=320GB
    if "!NominalSize:~0,3!" == "335" set NominalSize=360GB
    if "!NominalSize:~0,3!" == "447" set NominalSize=480GB
    if "!NominalSize:~0,3!" == "465" set NominalSize=500GB
    if "!NominalSize:~0,3!" == "476" set NominalSize=512GB
    if "!NominalSize:~0,3!" == "698" set NominalSize=750GB
    if "!NominalSize:~0,3!" == "931" set NominalSize=1TB
    if "!NominalSize:~0,3!" == "1.8" set NominalSize=2TB
    if "!NominalSize:~0,3!" == "2.7" set NominalSize=3TB
    if "!NominalSize:~0,3!" == "3.6" set NominalSize=4TB
    if "!NominalSize:~0,3!" == "4.5" set NominalSize=5TB
    if "!NominalSize:~0,3!" == "5.4" set NominalSize=6TB
    if "!NominalSize:~0,3!" == "7.2" set NominalSize=8TB
    if "!NominalSize:~0,3!" == "9.0" set NominalSize=10TB
    call :Space !Row!      8 Blank.1
    call :Space !Partitions!  9 Blank.2
    call :Space !InterfaceType! 12 Blank.3
    call :Space !NominalSize!  12 Blank.4
if not "!i:~1,1!"=="" echo.  !Row!!Blank.1!!Partitions!!Blank.2!!InterfaceType!!Blank.3!!NominalSize!!Blank.4!!Disklevel!    !DiskCaption!>>!File!
)
echo.>>!File!
echo.>>!File!
echo.  盘符  格式   容量    已用    剩余    卷标>>!File!
echo.>>!File!
for /f "skip=1 delims=" %%i in ('Wmic LogicalDisk Where Mediatype^='12' Get DeviceID^,FileSystem^,Size^,FreeSpace^,VolumeName') do (
    set i=%%i
    for /f "tokens=1,2,3,4,*" %%j in ("!i!") do (
        set DeviceID=%%j
        set FileSystem=%%k
        set FreeSpace=%%l
        set PartitionSize=%%m
        set VolumeName=%%n
        if "!VolumeName!"=="" set VolumeName=默认值
    )
    if "!FileSystem!"=="" (
        set FileSystem=RAW
        set Total=0.00GB
        set Used=0.00GB
        set Free=0.00GB
    ) Else (
        call :Minus !PartitionSize! !FreeSpace! PartitionUsed
        call :GetSize !FreeSpace! Free
        call :GetSize !PartitionSize! Total
        call :GetSize !PartitionUsed! Used
        if "!Free:~-5,3!"==".00" set Free=!Free:~0,-5!!Free:~-2!
        if "!Total:~-5,3!"==".00" set Total=!Total:~0,-5!!Total:~-2!
        if "!Used:~-5,3!"==".00" set Used=!Used:~0,-5!!Used:~-2!
        )
    call :Space !FileSystem! 9 Blank.1
    call :Space !Total!   12 Blank.2
    call :Space !Used!    12 Blank.3
    call :Space !Free!    12 Blank.4
if not "!i:~3,1!"=="" echo.  !DeviceID!   !FileSystem!!Blank.1!!Total!!Blank.2!!Used!!Blank.3!!Free!!Blank.4!!VolumeName!>>!File!
)
echo.>>!File!
echo.>>!File!
echo.关于显卡的详细信息如下:>>!File!
echo.>>!File!
echo.  名称 ........... : %VideoName%>>!File!
echo.>>!File!
echo.  显存 ........... : %AdapterRAM%>>!File!
echo.>>!File!
echo.  当前模式 ....... : %Resolution%>>!File!
echo.>>!File!
echo.  驱动版本 ....... : %DriverVersion%>>!File!
echo.>>!File!
echo.  驱动日期 ....... : %DriverDate%>>!File!
echo.>>!File!
echo.  内核名称 ....... : %VideoProcessor%>>!File!
echo.>>!File!
echo.>>!File!
echo.关于显示器的详细信息如下:>>!File!
echo.>>!File!
if "%DisplayName%" == "" set DisplayName=未获取
echo.  型号 ........... : %DisplayName%>>!File!
echo.>>!File!
echo.  像素密度 ....... : %PixelsPerXLogicalInch% Dpi>>!File!
echo.>>!File!
echo.  当前模式 ....... : %Resolution%>>!File!
if "%CD-ROM.Name%" neq "无" (
echo.>>!File!
echo.>>!File!
echo.关于光驱的详细信息如下:>>!File!
echo.>>!File!
echo. 列出所有光驱: >>!File!
echo.>>!File!
echo.  盘符  类型    型号 >>!File!
echo.>>!File!
for /f "skip=1 delims=" %%i in ('Wmic CdRom Get Name^,Drive^,Mediatype') do echo.  %%i>>!File!
)
echo.>>!File!
echo.>>!File!
echo.关于声卡的详细信息如下:>>!File!
echo.>>!File!
echo. 列出所有声卡: >>!File!
echo.>>!File!
set Row=0
for /f "delims== tokens=2" %%i in ('Wmic Sounddev Get ProductName /Value 2^>nul') do (
    set /a Row+=1
    echo.  !Row!. %%i>>!File!
)
echo.>>!File!
echo. 当前声卡信息: >>!File!
echo.>>!File!
set Row=0
for /f "tokens=2 delims=:" %%i in ('Findstr /IC:"Driver Version: " %Temp%\Dxdiag.dll') do (
    set /a Row+=1
    if !Row! == 2 set SoundDriverVersion=%%i
)
for /f "tokens=1,* delims=:" %%i in ('Findstr /IC:"Date and Size: " %Temp%\Dxdiag.dll') do (
    if "%%j"==" " (
        set SoundDate=未获取
        set SoundSize=未获取
        Goto :NoDateandSize) else (
    for /f "tokens=1,2 delims=," %%k in ("%%j") do (
        set SoundDate=%%k
        set SoundSize=%%l
    )))
for /f %%i in ("!SoundSize!") do call :GetSize %%i SoundSize
for /f %%i in ("!SoundDate!") do set SoundDate=%%i
 
for /f "tokens=1,2,3 delims=/" %%i in ("!SoundDate!") do (
    if %%i lss %%k set SoundDate=%%k 年 %%i 月 %%j 日
    if %%i gtr %%k set SoundDate=%%i 年 %%j 月 %%k 日
)
:NoDateandSize
echo.  输出声卡 ....... :!Description!>>!File!
echo.>>!File!
echo.  驱动版本 ....... :!SoundDriverVersion!>>!File!
echo.>>!File!
echo.  驱动日期 ....... : !SoundDate!>>!File!
echo.>>!File!
echo.  驱动大小 ....... : !SoundSize!>>!File!
echo.>>!File!
echo.>>!File!
echo.关于网卡的详细信息如下:>>!File!
echo.>>!File!
echo.  网卡名称 ....... : !NetName!>>!File!
echo.>>!File!
echo.  内网IP ......... : !IP!>>!File!
echo.>>!File!
echo.  网关 ........... : %DefaultIPGateway%>>!File!
echo.>>!File!
echo.  掩码 ........... : %IPSubnet%>>!File!
echo.>>!File!
echo.  MAC ............ : !MacAddress!>>!File!
echo.>>!File!
echo.  当前状态 ....... : !NetWorking!(外网)>>!File!
set Row=0
for /f "skip=2 tokens=2 delims==" %%i in ('Wmic Printer where "Default='TRUE'" get DriverName^,caption /value 2^>nul') do (
    set /a Row+=1
    if !Row! == 1 set PrinterName=%%i
    if !Row! == 2 set PrinterNamf=%%i
)
if "%PrinterName%" neq "" (
echo.>>!File!
echo.>>!File!
echo.关于打印机的详细信息如下:>>!File!
echo.>>!File!
echo.  名称 ........... : !PrinterName!>>!File!
echo.>>!File!
echo.  型号 ........... : !PrinterNamf!>>!File!
echo.>>!File!
echo.  说明 ........... : 只获取默认打印机信息>>!File!
)
set Row=0
for /f "skip=2 tokens=2 delims==" %%i in ('Wmic logicaldisk where "drivetype=2" get DeviceID^,FileSystem^,FreeSpace^,Size^,VolumeName^,VolumeSerialNumber /value 2^>nul') do (
    set /a Row+=1
    if !Row! == 1 set U.DeviceID=%%i
    if !Row! == 2 set U.FileSystem=%%i
    if !Row! == 3 set U.FreeSpace=%%i
    if !Row! == 4 set U.Size=%%i
    if !Row! == 5 set U.VolumeName=%%i
    if !Row! == 6 set U.VolumeSerialNumber=%%i
)
if "%U.FileSystem%"=="" set U.FileSystem=No
if "%U.FreeSpace%"=="" set U.FreeSpace=0
if "%U.Size%"=="" set U.Size=0
if "%U.VolumeName%"=="" set U.VolumeName=默认值
if "%U.VolumeSerialNumber%"=="" set U.VolumeSerialNumber=No
if "%U.DeviceID%" neq "" (
    call :Minus !U.Size! !U.FreeSpace! U.Used
    call :GetSize !U.FreeSpace! U.FreeSpace
    call :GetSize !U.Used! U.Used
    call :GetSize !U.Size! U.Size
    call :Space !U.FileSystem! 10 Blank.1
    call :Space !U.Size! 10 Blank.2
    call :Space !U.Used! 10 Blank.3
    call :Space !U.FreeSpace! 10 Blank.4
    call :Space !U.VolumeSerialNumber! 12 Blank.5
    echo.>>!File!
    echo.>>!File!
    echo.关于可移动磁盘的详细信息如下:>>!File!
    echo.>>!File!
    echo   盘符  格式   容量   已用   剩余   序列号   卷标>>!File!
    echo.>>!File!
    echo   %U.DeviceID%   %U.FileSystem%!Blank.1!!U.Size!!Blank.2!!U.Used!!Blank.3!!U.FreeSpace!!Blank.4!%U.VolumeSerialNumber%!Blank.5!%U.VolumeName%>>!File!
)
set U.DeviceID=
set Row=0
for /f "skip=10 tokens=2 delims==" %%i in ('Wmic logicaldisk where "drivetype=2" get DeviceID^,FileSystem^,FreeSpace^,Size^,VolumeName^,VolumeSerialNumber /value 2^>nul') do (
    set /a Row+=1
    if !Row! == 1 set U.DeviceID=%%i
    if !Row! == 2 set U.FileSystem=%%i
    if !Row! == 3 set U.FreeSpace=%%i
    if !Row! == 4 set U.Size=%%i
    if !Row! == 5 set U.VolumeName=%%i
    if !Row! == 6 set U.VolumeSerialNumber=%%i
)
if "%U.FileSystem%"=="" set U.FileSystem=No
if "%U.FreeSpace%"=="" set U.FreeSpace=0
if "%U.Size%"=="" set U.Size=0
if "%U.VolumeName%"=="" set U.VolumeName=默认值
if "%U.VolumeSerialNumber%"=="" set U.VolumeSerialNumber=No
if "%U.DeviceID%" neq "" (
    call :Minus !U.Size! !U.FreeSpace! U.Used
    call :GetSize !U.FreeSpace! U.FreeSpace
    call :GetSize !U.Used! U.Used
    call :GetSize !U.Size! U.Size
    call :Space !U.FileSystem! 10 Blank.1
    call :Space !U.Size! 10 Blank.2
    call :Space !U.Used! 10 Blank.3
    call :Space !U.FreeSpace! 10 Blank.4
    call :Space !U.VolumeSerialNumber! 12 Blank.5
    echo   %U.DeviceID%   %U.FileSystem%!Blank.1!!U.Size!!Blank.2!!U.Used!!Blank.3!!U.FreeSpace!!Blank.4!%U.VolumeSerialNumber%!Blank.5!%U.VolumeName%>>!File!
)
set U.DeviceID=
set Row=0
for /f "skip=18 tokens=2 delims==" %%i in ('Wmic logicaldisk where "drivetype=2" get DeviceID^,FileSystem^,FreeSpace^,Size^,VolumeName^,VolumeSerialNumber /value 2^>nul') do (
    set /a Row+=1
    if !Row! == 1 set U.DeviceID=%%i
    if !Row! == 2 set U.FileSystem=%%i
    if !Row! == 3 set U.FreeSpace=%%i
    if !Row! == 4 set U.Size=%%i
    if !Row! == 5 set U.VolumeName=%%i
    if !Row! == 6 set U.VolumeSerialNumber=%%i
)
if "%U.FileSystem%"=="" set U.FileSystem=No
if "%U.FreeSpace%"=="" set U.FreeSpace=0
if "%U.Size%"=="" set U.Size=0
if "%U.VolumeName%"=="" set U.VolumeName=默认值
if "%U.VolumeSerialNumber%"=="" set U.VolumeSerialNumber=No
if "%U.DeviceID%" neq "" (
    call :Minus !U.Size! !U.FreeSpace! U.Used
    call :GetSize !U.FreeSpace! U.FreeSpace
    call :GetSize !U.Used! U.Used
    call :GetSize !U.Size! U.Size
    call :Space !U.FileSystem! 10 Blank.1
    call :Space !U.Size! 10 Blank.2
    call :Space !U.Used! 10 Blank.3
    call :Space !U.FreeSpace! 10 Blank.4
    call :Space !U.VolumeSerialNumber! 12 Blank.5
    echo   %U.DeviceID%   %U.FileSystem%!Blank.1!!U.Size!!Blank.2!!U.Used!!Blank.3!!U.FreeSpace!!Blank.4!%U.VolumeSerialNumber%!Blank.5!%U.VolumeName%>>!File!
)
set U.DeviceID=
set Row=0
for /f "skip=26 tokens=2 delims==" %%i in ('Wmic logicaldisk where "drivetype=2" get DeviceID^,FileSystem^,FreeSpace^,Size^,VolumeName^,VolumeSerialNumber /value 2^>nul') do (
    set /a Row+=1
    if !Row! == 1 set U.DeviceID=%%i
    if !Row! == 2 set U.FileSystem=%%i
    if !Row! == 3 set U.FreeSpace=%%i
    if !Row! == 4 set U.Size=%%i
    if !Row! == 5 set U.VolumeName=%%i
    if !Row! == 6 set U.VolumeSerialNumber=%%i
)
if "%U.FileSystem%"=="" set U.FileSystem=No
if "%U.FreeSpace%"=="" set U.FreeSpace=0
if "%U.Size%"=="" set U.Size=0
if "%U.VolumeName%"=="" set U.VolumeName=默认值
if "%U.VolumeSerialNumber%"=="" set U.VolumeSerialNumber=No
if "%U.DeviceID%" neq "" (
    call :Minus !U.Size! !U.FreeSpace! U.Used
    call :GetSize !U.FreeSpace! U.FreeSpace
    call :GetSize !U.Used! U.Used
    call :GetSize !U.Size! U.Size
    call :Space !U.FileSystem! 10 Blank.1
    call :Space !U.Size! 10 Blank.2
    call :Space !U.Used! 10 Blank.3
    call :Space !U.FreeSpace! 10 Blank.4
    call :Space !U.VolumeSerialNumber! 12 Blank.5
    echo   %U.DeviceID%   %U.FileSystem%!Blank.1!!U.Size!!Blank.2!!U.Used!!Blank.3!!U.FreeSpace!!Blank.4!%U.VolumeSerialNumber%!Blank.5!%U.VolumeName%>>!File!
)
echo.>>!File!
echo.>>!File!
echo.>>!File!
echo.>>!File!
echo.程序版本 ..............................: V-2.2>>!File!
echo.>>!File!
set Tim.2=%time%
call :TimeDifference !Tim.1! !Tim.2! Difference
echo.生成详细信息耗时 ..................... : %Difference%>>!File!
for /f %%i in ("%date%") do set Dat=%%i
for /f "delims=." %%i in ("%Time%") do set Tim=%%i
echo.>>!File!
echo.此程序最后优化于 ..................... : 2020 年 03 月 18 日>>!File!
echo.>>!File!
echo.以上信息生成于 ........................: %Dat% %Tim%>>!File!
echo.>>!File!
del /a /f %Temp%\Dxdiag.dll >nul 2>nul
start !File!
:End
Exit
:Space
if "%~3" == "" Goto :eof
set S=%~1
set Len.2=%~2
set Space=
for /l %%i in (25 -1 1) do if "!S:~%%i,1!"=="" set Len.1=%%i
set /a Len.3=!Len.2!-!Len.1!
for /l %%i in (1 1 !Len.3!) do set Space=!Space!
set %~3=!Space!
Goto :eof
:GetSize
set Bytes=%~1
if "%~2" == "" Goto :eof
call :Division !Bytes! 1152921504606846976 OK
if not "%OK:~0,2%"=="0." (
    set %~2=!OK!EB
    Goto :eof
    ) else (call :Division !Bytes! 1125899906842624 OK)
if not "%OK:~0,2%"=="0." (
    set %~2=!OK!PB
    Goto :eof
    ) else (call :Division !Bytes! 1099511627776 OK)
if not "%OK:~0,2%"=="0." (
    set %~2=!OK!TB
    Goto :eof
    ) else (call :Division !Bytes! 1073741824 OK)
if not "%OK:~0,2%"=="0." (
    set %~2=!OK!GB
    Goto :eof
    ) else (call :Division !Bytes! 1048576 OK)
if not "%OK:~0,2%"=="0." (
    set %~2=!OK!MB
    Goto :eof
    ) else (call :Division !Bytes! 1024 OK)
if not "%OK:~0,2%"=="0." (
    set %~2=!OK!KB
    Goto :eof
    ) else (
    set %~2=!Bytes!B
    Goto :eof)
:TimeDifference
set /a N=0
for /f "tokens=1-8 delims=.:" %%I in ("%~2:%~1") do (
    set /a N+=10%%I%%100*360000+10%%J%%100*6000+10%%K%%100*100+10%%L%%100
    set /a N-=10%%M%%100*360000+10%%N%%100*6000+10%%O%%100*100+10%%P%%100
)
set Sco=!N!
set /a S=N/360000,N=N%%360000,F=N/6000,N=N%%6000,M=N/100,N=N%%100
set T=%M% 秒 %N% 毫秒
set %~3=%T%
Goto :eof
:Calc
set Cal.1=%~1
set Cal.2=%~2
set Cal.3=0
set Cal.4=
for %%i in (!Smart!) do (set /a Cal.3+=1
    if !Cal.3! Geq !Cal.1! (if !Cal.3! Lss !Cal.2! set Cal.4=!Cal.4! %%i))
for /f "tokens=6,7" %%i in ("!Cal.4!") do set /a Cal.4=%%j*256+%%i
set %~3=!Cal.4!
Goto :eof
:Inspect
title 获取硬件信息 - 正在检测运行环境,请稍等...
if %~Z0 neq 40938 Exit
if /i "%systemDrive%" == "X:" Title 此程序不支持 PE 环境,请安任意键退出!& Pause>nul & exit
Net User Guest /Active:Yes>nul 2>nul
if /i %Errorlevel% neq 0 Title 当前账户权限不足,请以管理员身份运行!& Pause>nul & exit
set Tit=关于电脑配置的简要信息如下:
set Titl=关于电脑配置的详细信息如下:
Sc Config Winmgmt Start= Auto >nul 2>nul
for /f "tokens=2 delims==" %%i in ('Wmic DiskDrive Get Model /Value^|Find /i /v "USB"') do (
    echo %%i>%Temp%\Temp.txt
    for /f %%j in ('Findstr /i "Vmware Vbox Virtual Qemu" %Temp%\Temp.txt') do (
        if "%%j" neq "" (Color 03
                 set Tit=检测环境处于虚拟机中,以下信息可能不准:
                 set Titl=检测环境处于虚拟机中,以下信息可能不准:
        )
    )
    del /a /f %Temp%\Temp.txt >nul 2>nul
)
Goto :eof
:Addition
if "%~3"=="" Goto :eof
set Add.1=%~1
set Add.2=%~2
set Add.3=
set Add.3.Temp.1=
set Add.3.Temp.2=0
set Add.1.Temp=
for /l %%i in (25 -1 0) do (if "!Add.1:~%%i,1!"=="" set Add.1.Len=%%i
              if "!Add.2:~%%i,1!"=="" set Add.2.Len=%%i)
if !Add.1.Len! lss !Add.2.Len! (set Add.1=%~2
                set Add.2=%~1)
for /l %%i in (0 1 9) do set Add.1=!Add.1:%%i=%%i !
for %%i in (!Add.1!) do set Add.1.Temp=%%i !Add.1.Temp!
if %~Z0 neq 40938 Goto :End
for %%i in (!Add.1.Temp!) do (
    if "!Add.2!"=="" set Add.2=0
    set /a Add.3.Temp.1=%%i+!Add.2:~-1!+!Add.3.Temp.2!
    set Add.3=!Add.3.Temp.1:~-1!!Add.3!
    set Add.3.Temp.2=!Add.3.Temp.1:~0,-1!
    if "!Add.3.Temp.2!"=="" set Add.3.Temp.2=0
    set Add.2=!Add.2:~0,-1!
)
if !Add.3.Temp.2! neq 0 set Add.3=!Add.3.Temp.2!!Add.3!
for /f "tokens=* delims=0" %%i in ("!Add.3!") do set Add.3=%%i
if "!Add.3!"=="" set Add.3=0
set %~3=!Add.3!
Goto :eof
:Minus
if "%~3"=="" Goto :eof
set Min.0=0
set Min.1=%~1
set Min.2=%~2
set Min.3=
set Min.1.Temp=
for /l %%i in (0 1 9) do set Min.1=!Min.1:%%i= %%i!
for %%i in (!Min.1!) do set Min.1.Temp=%%i !Min.1.Temp!
for %%i in (!Min.1.Temp!) do (
    set Min.i=%%i
    if "!Min.2!"=="" set Min.2=0
    if !Min.0! == 10 set /a Min.i=!Min.i!-1
    if !Min.2:~-1! gtr !Min.i! (set Min.0=10) else set Min.0=0
    set /a Min.3.Temp=!Min.i!+!Min.0!-!Min.2:~-1!
    set Min.3=!Min.3.Temp!!Min.3!
    set Min.2=!Min.2:~0,-1!
    )
for /f "tokens=* delims=0" %%i in ("!Min.3!") do set Min.3=%%i
if "!Min.3!"=="" set Min.3=0
set %~3=!Min.3!
Goto :eof
:Division
if "%~3" == "" Goto :eof
setlocal
set Div.1=%~1
set Div.2=%~2
set Div.3=
set Dec.d=2
set Zer.O=00000000
for /l %%i in (1 1 7) do set Zer.O=!Zer.O!!Zer.O!
set Halving=4096 2048 1024 512 256 128 64 32 16 8 4 2 1
for /l %%i in (1 1 2) do (set i=0& set Div.%%i.Len.2=0
    for %%j in (!Div.%%i:.^= !) do (
        set /a i+=1& set jj=jj%%j& set Div.%%i.Len.!i!=0
        for %%k in (!Halving!) do (if "!jj:~%%k!" neq "" set /a Div.%%i.Len.!i!+=%%k& set jj=!jj:~%%k!)
        set /a Div.%%i.Len.0+=Div.%%i.Len.!i!
    )
    set Div.%%i=!Div.%%i:.=!
)
if !Div.1.Len.2! gtr !Div.2.Len.2! (set /a Div.2.Len.0+=Div.1.Len.2-Div.2.Len.2) else (set /a Div.1.Len.0+=Div.2.Len.2-Div.1.Len.2)
for /l %%i in (1 1 2) do (set Div.%%i=!Div.%%i!!Zer.O!
    for %%j in (!Div.%%i.Len.0!) do set Div.%%i=!Div.%%i:~,%%j!
)
for /f "tokens=* delims=0" %%i in ("!Div.2!") do set N=%%i& set Div.2=0%%i
set Div.2.Len.0=1
for %%j in (!Halving!) do (if "!N:~%%j!" neq "" (set /a Div.2.Len.0+=%%j& set N=!N:~%%j!))
set /a Div.Len=Div.2.Len.0+1
if !Div.1.Len.0! lss !Div.2.Len.0! set Div.1.Len.0=!Div.2.Len.0!& set Div.1=!Zer.O:~-%Div.2.Len.0%,-%Div.1.Len.0%!!Div.1!
set /a Div.1.Len.0+=Dec.d
set Div.X=%~Z0
set /a Div.Y=31415+9523
if !Div.X! neq !Div.Y! goto :eof
set Div.1=0!Div.1!!Zer.O:~,%Dec.d%!
set Div=!Div.1:~,%Div.2.Len.0%!
set i=0000000!Div.2!
set /a Len=Div.2.Len.0+7
for /l %%i in (1 1 9) do (set T=0
    for /l %%j in (8 8 !Len!) do (set /a T=1!i:~-%%j,8!*%%i+T
        set Num%%i=!T:~-8!!Num%%i!
        set /a T=!T:~,-8!-%%i
    )
    set Num%%i=!T!!Num%%i!
    set Num%%i=0000000!Num%%i:~-%Div.Len%!
)
for /l %%l in (!Div.2.Len.0! 1 !Div.1.Len.0!) do (
    set Div=!Zer.O!!Div!!Div.1:~%%l,1!
    set Div=!Div:~-%Div.Len%!
    if "!Div!" geq "!Div.2!" (
        set M=1& set i=0000000!Div!
        for /l %%i in (2 1 9) do if !i! geq !Num%%i! set M=%%i
        set Div.3=!Div.3!!M!
        set Div=
        set T=0
        for %%i in (!M!) do (
            for /l %%j in (8 8 !Len!) do (
                set /a T=3!i:~-%%j,8!-1!Num%%i:~-%%j,8!-!T:~,1!%%2
                set Div=!T:~1!!Div!
             )
        )  
    ) else set Div.3=!Div.3!0
)
if defined Dec.d if %Dec.d% gtr 0 set Div.3=!Div.3:~,-%Dec.d%!.!Div.3:~-%Dec.d%!
for /f "tokens=* delims=0" %%i in ("!Div.3!") do set Div.3=%%i
if "!Div.3:~0,1!"=="." set Div.3=0!Div.3!
endlocal & set %~3=%Div.3%
Goto :eof
Rem QQ:540044977 2020-04-29

说明:此程序纯批处理,且纯净绿色,也不会在生成文件中包含我的个人信息,大家不要随意修改里面的代码结构,很可能自己电脑没问题,到了别的电脑就会获取不准。

原文链接:http://www.bathome.net/thread-38259-1-1.html

延伸 · 阅读

精彩推荐
  • bat批处理重命名系列案例代码

    批处理重命名系列案例代码

    这篇文章主要介绍了批处理重命名系列案例代码,需要的朋友可以参考下...

    张戈10372021-10-07
  • batWindows下用bat命令行方式更改IE代理服务器设置方法

    Windows下用bat命令行方式更改IE代理服务器设置方法

    批处理(Batch),也称为批处理脚本。顾名思义,批处理就是对某对象进行批量的处理,批处理文件的扩展名为bat,下面通过本文给大家分享Windows下用bat命令...

    大萝卜空心的6202021-10-06
  • bat让bat批处理以管理员权限运行的实现方法

    让bat批处理以管理员权限运行的实现方法

    这篇文章主要介绍了让bat批处理以管理员权限运行的实现方法,需要的朋友可以参考下...

    bat教程网6962021-10-08
  • bat变量延迟详解 call setlocal

    变量延迟详解 call setlocal

    变量延迟在for语句中起着至关重要的作用,不只是在for语句中,在其他的复合语句中,它也在幕后默默地工作着,为了突出它的重要性,本节内容在单独的...

    脚本之家5742021-10-08
  • batWindows批处理更改当前工作路径的BAT

    Windows批处理更改当前工作路径的BAT

    最近项目上需要获取文件夹下所有文件信息,因为文件夹是在server上,所以想用批处理bat来获取该路径下所有文件信息,然后通过任务计划管理去每天自动...

    脚本之家12122021-10-07
  • bat使用 windows bat 脚本命令一键启动MySQL服务的方法

    使用 windows bat 脚本命令一键启动MySQL服务的方法

    这篇文章主要介绍了使用 windows bat 脚本命令 一键启动MySQL服务的方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的...

    明金同学14752021-10-07
  • batbat实现一分钟清除系统中所有垃圾文件

    bat实现一分钟清除系统中所有垃圾文件

      在桌面上点鼠标右键,选择新建一个“记事本”,把下面的字复制进去,点“另存为”,把文件名定为“清除系统垃圾.bat”就完成,记住后缀名一定要...

    批处理之家10592021-11-14
  • batbat过滤任意字符

    bat过滤任意字符

    早在写 bat的一个小游戏猜数字的时候我就研究过这个问题 如何在bat里面实现 对输入的任意字符进行过滤 当时使用的几种方法如下 ...

    allyesno11802021-12-26