|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Get Dotnet Framework version from command lineHi everybody,
I write a VBS script witch uses csc.exe (command line dotnet compiler), but my problem is to detect what version of Dotnet Framework is installed on the server to use the good repertory 1.1 or 2.0 (v1.1.4322 or v2.0.50215 ...) What command line or script can I use to get this information ? Thanks to all for any advice Bruno >I write a VBS script witch uses csc.exe (command line dotnet compiler), You can have both installed. If you simply want to use v2 if available>but my problem is to detect what version of Dotnet Framework is >installed on the server to use the good repertory 1.1 or 2.0 (v1.1.4322 >or v2.0.50215 ...) >What command line or script can I use to get this information ? and otherwise fall back on v1.1, can't you simply check if %WINDIR%\Microosft.NET\Framework\v2.0.50727\csc.exe exists? Mattias -- Mattias Sjögren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup. Yes I can, but how can I check if a newer version is installed in the
future ? Bruno Mattias Sjögren wrote: Show quote > >I write a VBS script witch uses csc.exe (command line dotnet compiler), > >but my problem is to detect what version of Dotnet Framework is > >installed on the server to use the good repertory 1.1 or 2.0 (v1.1.4322 > >or v2.0.50215 ...) > >What command line or script can I use to get this information ? > > > You can have both installed. If you simply want to use v2 if available > and otherwise fall back on v1.1, can't you simply check if > %WINDIR%\Microosft.NET\Framework\v2.0.50727\csc.exe exists? > > > Mattias > > -- > Mattias Sjögren [C# MVP] mattias @ mvps.org > http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com > Please reply only to the newsgroup. bcasta***@gmail.com wrote:
Show quote > Mattias Sjögren wrote: On the other hand, how would you know if the code you're trying to> > bcasta***@gmail.com wrote: > > >I write a VBS script witch uses csc.exe (command line dotnet compiler), > > >but my problem is to detect what version of Dotnet Framework is > > >installed on the server to use the good repertory 1.1 or 2.0 (v1.1.4322 > > >or v2.0.50215 ...) > > >What command line or script can I use to get this information ? > > > > > > You can have both installed. If you simply want to use v2 if available > > and otherwise fall back on v1.1, can't you simply check if > > %WINDIR%\Microosft.NET\Framework\v2.0.50727\csc.exe exists? > > > > > > Mattias > > > > -- > > Mattias Sjögren [C# MVP] mattias @ mvps.org > > http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com > > Please reply only to the newsgroup. > Yes I can, but how can I check if a newer version is installed in the > future ? > > Bruno > compile uses deprecated/unsupported features, or features for which breaking changes have been made, in a later version of the framework. Your situation is: you *know* (or have good reason to suspect) that your code compiles with C# 2.0. You *know* (or have good...) that your code compiles with C# 1.1. Your code may work with C#3.0 beta. Does your code compile with version 4, with version 5, etc? I've taken a quick scan through the registry, but there doesn't seem to be anything obvious. You could try enumerating keys under HKLM\Software\Microsoft\NET Framework Setup\NDP and getting the latest version, then looking under the directory you can find through the InstallRoot value under the HKLM\Software\Microsoft\.NET Framework key. (Or directly search the directories under that directory for directories which match the patter vn.n.nnnn) In either case, you'll be dealing with strings and you'll have to do careful parsing (if you're really future-proofing) that, for instance, v10.0 sorts higher then v2. Good luck! Damien Hi,
The Microsoft.NET registry key seems to be different between version 1.1 or 2.0, so do you the better solution to get the actual version installed ? Is it listing %WINDIR%\Microosft.NET\Framework\*. and sort the result and get the highest value ? Or WMI fonction ? Do you know a script to do any working solution ? Thanks Bruno Damien a écrit : Show quote > bcasta***@gmail.com wrote: > > Mattias Sjögren wrote: > > > bcasta***@gmail.com wrote: > > > >I write a VBS script witch uses csc.exe (command line dotnet compiler), > > > >but my problem is to detect what version of Dotnet Framework is > > > >installed on the server to use the good repertory 1.1 or 2.0 (v1.1.4322 > > > >or v2.0.50215 ...) > > > >What command line or script can I use to get this information ? > > > > > > > > > You can have both installed. If you simply want to use v2 if available > > > and otherwise fall back on v1.1, can't you simply check if > > > %WINDIR%\Microosft.NET\Framework\v2.0.50727\csc.exe exists? > > > > > > > > > Mattias > > > > > > -- > > > Mattias Sjögren [C# MVP] mattias @ mvps.org > > > http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com > > > Please reply only to the newsgroup. > > Yes I can, but how can I check if a newer version is installed in the > > future ? > > > > Bruno > > > On the other hand, how would you know if the code you're trying to > compile uses deprecated/unsupported features, or features for which > breaking changes have been made, in a later version of the framework. > > Your situation is: you *know* (or have good reason to suspect) that > your code compiles with C# 2.0. You *know* (or have good...) that your > code compiles with C# 1.1. Your code may work with C#3.0 beta. Does > your code compile with version 4, with version 5, etc? > > I've taken a quick scan through the registry, but there doesn't seem to > be anything obvious. You could try enumerating keys under > HKLM\Software\Microsoft\NET Framework Setup\NDP and getting the latest > version, then looking under the directory you can find through the > InstallRoot value under the HKLM\Software\Microsoft\.NET Framework key. > (Or directly search the directories under that directory for > directories which match the patter vn.n.nnnn) > > In either case, you'll be dealing with strings and you'll have to do > careful parsing (if you're really future-proofing) that, for instance, > v10.0 sorts higher then v2. > > Good luck! > > Damien |
|||||||||||||||||||||||