由于某种原因,我无法在 IF 语句中打印 %NetVerClientOrFull% 。这真的很奇怪,因为它有时会,有时甚至在我不改变任何东西时也不会。我已经在多台机器上进行了测试,结果相同。如果我在 IF 语句中使用 %NetVer% ,则始终打印。有什么想法吗?
ECHO 客户端还是完整版?%NetVerClientOrFull%(应显示 Client 或 Full,有时会显示)
@echo off
set frameworkDirectory=Reg query "HKLM\Software\Microsoft\NET Framework Setup\NDP"
FOR /F "TOKENS=6 DELIMS=\." %%A IN ('%frameworkDirectory%') DO set NetVer=%%A
ECHO The most current version of the .NET Framework installed is: %NetVer%
if "%NetVer%"=="v4" (
set clientOrFullDirectory=Reg query "HKLM\Software\Microsoft\NET Framework Setup\NDP\v4"
FOR /F "TOKENS=7 DELIMS=\." %%A IN ('%clientOrFullDirectory%') DO set NetVerClientOrFull=%%A
ECHO Client or Full? %NetVerClientOrFull%
)
pause
要添加到这一点,它似乎在我的第三次运行中有效,没有任何意义:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\Nick>C:\Users\Nick\Desktop\FrameworkVersionChecker.bat
The most current version of the .NET Framework installed is: v4
Client or Full?
Press any key to continue . . .
C:\Users\Nick>C:\Users\Nick\Desktop\FrameworkVersionChecker.bat
The most current version of the .NET Framework installed is: v4
Client or Full?
Press any key to continue . . .
C:\Users\Nick>C:\Users\Nick\Desktop\FrameworkVersionChecker.bat
The most current version of the .NET Framework installed is: v4
Client or Full? Full
Press any key to continue . . .