tags:

views:

1725

answers:

2

Is there anything similar to the following in Windows that will let me know if .NET is installed from the command line?

$ java -version
$ ruby --version
$ python --version
+5  A: 

What OS and command shell are you using?

With Windows from a batch file

if EXIST %WINDIR%\Microsoft.Net\Framework\v1.0.3705\mscorlib.dll
if EXIST %WINDIR%\Microsoft.Net\Framework\v1.1.4322\mscorlib.dll
if EXIST %WINDIR%\Microsoft.Net\Framework\v2.0.50727\mscorlib.dll

With Windows from PowerShell

if (test-path (join-path $env:windir "Microsoft.Net\Framework\v2.0.50727\mscorlib.dll"))){
JaredPar
The question is "if" .net is installed. Can't run powershell if it isn't.
EBGreen
@EBGreen, the questioner didn't specify a version. It's possible to have powershell without all versions of the framework (v1,v1.1 and eventually v4.0). I tried to make the answer as complete as possible.
JaredPar
The way that the question is worded, he just wants to determine if .net is installed at all. Any version. Now you may be right that he actually wants to know the version, but that isn't the way that the question is written.
EBGreen
so is it safe to assume that some version of .NET is installed if the Microsoft.Net folder is present in %WINDIR%?
Abdullah Jibaly
It is likely, but I would say that there are potential instances where that would not be the case. For instance if someone had uninstalled it is possible that the root folder would be left behind.
EBGreen
Jared is right that the best bet is to check for the existence of one of a version of mscorlib.dll.
EBGreen
@EBGreen,@Abdullah, It's unfortunately not unrare for the framework folder to be present but not be installed. On my Vista machine a I have the 1.0, 1.1 and 2.0 folder but only the 2.0 framework is actually installed
JaredPar
A: 

You can use clrver command to check which .net frameworks are installed.

Shekhar