tags:

views:

1859

answers:

3

I have set of scripts for doing scripted installs. You can use the scripts on any server 2008 machine. However, I need to check if .NET 3.5 has been installed (before the scripts run) using a dos batch file. Is that possible?

I know I can check if a file in the C:\WINDOWS\Microsoft.NET\Framework\v3.5 exists, but it would be nice to have something a little more reliable.

I would like to check if it's actually installed, not just if the dir/file exists.

Hope that makes sense.

Thanks in advance.

+1  A: 

Unfortunately the best way would be to check for that directory. I am not sure what you mean but "actually installed" as .NET 3.5 uses the same CLR as .NET 3.0 and .NET 2.0 so all new functionality is wrapped up in new assemblies that live in that directory. Basically, if the directory is there then 3.5 is installed.

Only thing I would add is to find the dir this way for maximum flexibility:

%windir%\Microsoft.NET\Framework\v3.5
Andrew Hare
Thanks for the help. I think checking for the dir will work just fine. Also, thanks for the reminder about using %windir%
+2  A: 

You can write yourself a little console app and use System.Environment.Version to find out the version. Scott Hanselman gives a blog post about it.

Or look in the registry for the installed versions. HKLM\Software\Microsoft\NETFramework Setup\NDP

ajma
Gotta love it - Hanselman's blog has a widget that displays "Now playing: Alicia Keys - If I Was Your Woman/Walk On By" linked to the iTunes store. :D
le dorfier
Only problem is my scripts might be run on a freshly installed vm with nothing but the base OS. I think checking for the dir exist will work for what I need.
If you care about SP1 versus non SP1, you're going to have use something else, like checking the registry.
ajma
+1  A: 

If you're going to run a little console app, you may as well install clrver.exe from the .NET SDK. I don't think you can get cleaner than that. This isn't my answer (but I happen to agree), I found it here.

uncle brad