Since you said you want to know if its actually installed, I think the best way (short of running version specific code), is to check the reassuringly named "Install" registry key. 0x1 means yes:
C:>reg query "HKLMSOFTWAREMicrosoftNET Framework SetupNDPv3.5"| findstr Install
Install REG_DWORD 0x1
InstallPath REG_SZ c:WINNTMicrosoft.NETFrameworkv3.5
This also happens to be the "Microsoft Recommended" official method.
WMI is another possibility, but seems impractical (Slow? Takes 2 min on my C2D, SSD). Maybe it works better on your server:
C:>wmic product where "Name like 'Microsoft .Net%'" get Name, Version
Name Version
Microsoft .NET Compact Framework 1.0 SP3 Developer 1.0.4292
Microsoft .NET Framework 3.0 Service Pack 2 3.2.30729
Microsoft .NET Framework 3.5 SP1 3.5.30729
Microsoft .NET Compact Framework 2.0 2.0.5238
Microsoft .NET Framework 4 Client Profile 4.0.30319
Microsoft .NET Framework 4 Multi-Targeting Pack 4.0.30319
Microsoft .NET Framework 2.0 Service Pack 2 2.2.30729
Microsoft .NET Framework 1.1 1.1.4322
Microsoft .NET Framework 4 Extended 4.0.30319
C:>wmic product where "name like 'Microsoft .N%' and version='3.5.30729'" get name
Name
Microsoft .NET Framework 3.5 SP1
Other than these I think the only way to be 100% sure is to actually run a simple console app compiled targeting your framework version. Personally, I consider this unnecessary and trust the registry method just fine.
Finally, you could set up an intranet test site which is reachable from your server and sniffs the User Agent to determine .NET versions. But that's not a batch file solution of course. Also see doc here.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…