标题: [其他] PE里确定系统版本 求助批处理变量调用问题 for 里面 [打印本页]
作者: dong3626 时间: 2023-4-19 21:25 标题: PE里确定系统版本 求助批处理变量调用问题 for 里面
PE里确定系统版本 求助一个变量调用问题 for 里面
问题在第 19-22行的代码位置
请大神们指教,优化代码
谢谢- @echo off
- setlocal enabledelayedexpansion
-
- set "$5.1.26=WinXP"
- set "$5.2.00=WinXP 64 "
- set "$6.0.60=Vista /S2008 "
- set "$6.1.76=Win7 /S2008 R2"
- set "$6.2.92=Win8 /S2012 "
- set "$6.3.96=Win8.1/S2012R2 "
- set "$10.0.1=Win10 /S2016-9 "
- set "$10.0.2=Wind11/S2022 "
-
- :: 遍历磁盘,确定盘符占用,并返回系统版本
- for %%a in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
- if exist %%a:\ (
- if exist "%%a:\windows\system32\version.dll" (
- echo %%a
- for /f "tokens=2 delims==" %%b in ('wmic datafile where Name^="%%a:\\Windows\\explorer.exe" get Version /value') do (
- call echo %%b
- set "tmp=%%b"
- set "x=!tmp:~0,6!"
- set "xx=$!x!"
- )
- for /f "tokens=2 delims==" %%b in ('wmic datafile where Name^="%%a:\\Windows\\System32\\version.dll" get Version /value') do (call echo %%b)
- if exist "%%a:\boot\memtest.ext" (echo BIOS) else (echo UEFI)
- )
- )
- )
-
-
- echo !x!
- echo !xx!
-
- echo --------------
-
- set
-
- PAUSE>NUL
复制代码
作者: Batcher 时间: 2023-4-19 21:41
回复 1# dong3626 - @echo off
- setlocal enabledelayedexpansion
-
- set "$5.1.26=WinXP"
- set "$5.2.00=WinXP 64 "
- set "$6.0.60=Vista /S2008 "
- set "$6.1.76=Win7 /S2008 R2"
- set "$6.2.92=Win8 /S2012 "
- set "$6.3.96=Win8.1/S2012R2 "
- set "$10.0.1=Win10 /S2016-9 "
- set "$10.0.2=Wind11/S2022 "
-
- REM 遍历磁盘,确定盘符占用,并返回系统版本
- for %%a in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
- if exist "%%a:\windows\system32\version.dll" (
- echo %%a
- for /f "tokens=2 delims==" %%b in ('wmic datafile where Name^="%%a:\\Windows\\explorer.exe" get Version /value') do (
- echo,%%b
- set "tmp=%%b"
- set "x=!tmp:~0,6!"
- call set "xx=%%$!x!%%"
- )
- for /f "tokens=2 delims==" %%b in ('wmic datafile where Name^="%%a:\\Windows\\System32\\version.dll" get Version /value') do (
- echo,%%b
- )
- if exist "%%a:\boot\memtest.ext" (
- echo BIOS
- ) else (
- echo UEFI
- )
- )
- )
-
- echo,!x!
- echo,!xx!
- pause
复制代码
作者: dong3626 时间: 2023-4-19 21:48
本帖最后由 dong3626 于 2023-4-19 22:00 编辑
回复 dong3626
Batcher 发表于 2023-4-19 21:41
感谢回答
那部分代码应该能简化,只是想获得系统版本
请赐教,这是哪一部分知识 再次谢谢
经指教,代码优化为:- @echo off
- setlocal enabledelayedexpansion
-
- set "$5.1.26=WinXP"
- set "$5.2.00=WinXP 64 "
- set "$6.0.60=Vista /S2008 "
- set "$6.1.76=Win7 /S2008 R2"
- set "$6.2.92=Win8 /S2012 "
- set "$6.3.96=Win8.1/S2012R2 "
- set "$10.0.1=Win10 /S2016-9 "
- set "$10.0.2=Wind11/S2022 "
-
- :: 遍历磁盘,确定盘符占用,并返回系统版本
- for %%a in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
- if exist %%a:\ (
- if exist "%%a:\windows\system32\version.dll" (
- for /f "tokens=2 delims==" %%b in ('wmic datafile where Name^="%%a:\\Windows\\explorer.exe" get Version /value') do (
- set "tmp=%%b"
- set "x=!tmp:~0,6!"
- call set "xx=%%$!x!%%"
- set pf=%%a
- echo !pf! 盘存在系统 !xx!
- )
- if exist "%%a:\boot\memtest.ext" (echo %%a 盘引导方式 BIOS) else (echo %%a 盘引导方式 UEFI)
- )
- )
- )
-
- echo --------------
-
- PAUSE>NUL
复制代码
作者: Batcher 时间: 2023-4-20 17:02
回复 3# dong3626
批处理中的变量嵌套
http://bbs.bathome.net/thread-2899-1-1.html
作者: 807979023 时间: 2023-4-20 18:54
7和10正常,xp出错
xp
6.00.2900.5512
7
6.1.7600.17514
10
10.0.14393.0
作者: dong3626 时间: 2023-4-22 11:21
回复 5# 807979023
网上找的版本号
我这没有xp系统
请自行验证
居然还有xp系统,佩服
作者: 807979023 时间: 2023-4-22 11:45
改了一句,好像可以了.
@echo off&color 1f&echo.
setlocal enabledelayedexpansion
set "$5.1.26=winXP "
set "$6.1.76=win7 "
set "$6.2.92=win8 "
set "$6.3.96=win8.1"
set "$10.0.1=win10 "
set "$10.0.2=wind11"
:: 遍历磁盘,确定盘符占用,并返回系统版本
for %%a in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
if exist %%a:\ (
if exist "%%a:\windows\system32\version.dll" (
if /i not exist "%%a:\windows\syswow64" (set vx=x32)else (set vx=x64)
for /f "tokens=2 delims==" %%b in ('wmic datafile where Name^="%%a:\\Windows\\System32\\version.dll" get Version /value') do (
set "tmp=%%b"
set "x=!tmp:~0,6!"
call set "xx=%%$!x!%%"
set pf=%%a
echo !pf!盘 !xx! !vx!
)
)
)
)
echo.&echo 按任意键退出...&pause >nul&exit
作者: terse 时间: 2023-4-22 11:49
这里wmic结果和ver应该一样的吧
作者: 807979023 时间: 2023-4-22 12:33
ver只能查当前系统,多系统好像查不到,我硬盘上有3个系统。
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |