From: DetRich on
Hello,

I am trying to write a vbscript that will tell me what, if any, versions of
the Microsoft .NET framework is installed. I have found several, but none
that will identify if .NET 3.5 or higher is installed.

My thoughts on one method is that if folder a folder exists where the folder
name starts with "v" followed by a number, then that version of .Net is
installed.

So, I get to the C:\windows\Microsoft.NET\Framework folder. First, how do I
identify the folders and not the files? I think these folders become part of
a collection. I then loop through the collection and examine each folder
name. Using string functions, if the folder name matches the criteria, I
write out a messages stating the folder name as the version of .Net that is
installed.

Can anyone assist me with this, or point me to a good code sample?

TIA,

DetRich
From: Pegasus [MVP] on


"DetRich" <DetRich(a)discussions.microsoft.com> wrote in message
news:8A86D51A-2728-46B7-9F51-A87FE4BE9E43(a)microsoft.com...
> Hello,
>
> I am trying to write a vbscript that will tell me what, if any, versions
> of
> the Microsoft .NET framework is installed. I have found several, but none
> that will identify if .NET 3.5 or higher is installed.
>
> My thoughts on one method is that if folder a folder exists where the
> folder
> name starts with "v" followed by a number, then that version of .Net is
> installed.
>
> So, I get to the C:\windows\Microsoft.NET\Framework folder. First, how do
> I
> identify the folders and not the files? I think these folders become part
> of
> a collection. I then loop through the collection and examine each folder
> name. Using string functions, if the folder name matches the criteria, I
> write out a messages stating the folder name as the version of .Net that
> is
> installed.
>
> Can anyone assist me with this, or point me to a good code sample?
>
> TIA,
>
> DetRich

Here you go:
sFolder = "C:\windows\Microsoft.NET\Framework"
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder(sFolder)
For Each oSubfolder In oFolder.SubFolders
WScript.echo oSubfolder.name
Next

I strongly recommend you download the helpfile script56.chm from the
Microsoft site. It contains the syntax and numerous examples for all the
basic VB Script functions.

From: Mayayana on
Here's a script I wrote to spoof dotnet support. It
deals with the values up to 3.5. You'll just need to
look up what the value for v. 4 is. Using these
Reg. values should be easier and more dependable
than walking a folder tree.

I'm just pasting the whole script. You can deduce what
you need from that.

If Ret = 6 then ' if person has chosen to write spoof values to Reg.

s1 = "HKLM\SOFTWARE\Microsoft\.NETFramework\policy\v1.0"
SH.RegWrite s1, "3705", "REG_SZ"

s1 = "HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v1.1.4322\Install"
SH.RegWrite s1, 1, "REG_DWORD"
s1 = "HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v1.1.4322\SP"
SH.RegWrite s1, 3, "REG_DWORD"
s1 = "HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v1.1.4322\MSI"
SH.RegWrite s1, 3, "REG_DWORD"

s1 = "HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v2.0.50727\Install"
SH.RegWrite s1, 1, "REG_DWORD"
s1 = "HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v2.0.50727\SP"
SH.RegWrite s1, 3, "REG_DWORD"
s1 = "HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v2.0.50727\MSI"
SH.RegWrite s1, 3, "REG_DWORD"

s1 = "HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5\Install"
SH.RegWrite s1, 1, "REG_DWORD"
s1 = "HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5\SP"
SH.RegWrite s1, 3, "REG_DWORD"
s1 = "HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5\MSI"
SH.RegWrite s1, 3, "REG_DWORD"

s1 = "HKLM\SOFTWARE\Microsoft\NET Framework
Setup\NDP\v3.0\Setup\InstallSuccess"
SH.RegWrite s1, 1, "REG_DWORD"
s1 = "HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.0\Setup\SP"
SH.RegWrite s1, 3, "REG_DWORD"
s1 = "HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.0\Setup\MSI"
SH.RegWrite s1, 3, "REG_DWORD"

Else 'delete .Net keys from Reg.

SH.RegDelete "HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.0\Setup\"
SH.RegDelete "HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5\"
SH.RegDelete "HKLM\SOFTWARE\Microsoft\NET Framework
Setup\NDP\v2.0.50727\"
SH.RegDelete "HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v1.1.4322\"
SH.RegDelete "HKLM\SOFTWARE\Microsoft\.NETFramework\policy\"
End If




|
| I am trying to write a vbscript that will tell me what, if any, versions
of
| the Microsoft .NET framework is installed. I have found several, but none
| that will identify if .NET 3.5 or higher is installed.
|
| My thoughts on one method is that if folder a folder exists where the
folder
| name starts with "v" followed by a number, then that version of .Net is
| installed.
|
| So, I get to the C:\windows\Microsoft.NET\Framework folder. First, how do
I
| identify the folders and not the files? I think these folders become part
of
| a collection. I then loop through the collection and examine each folder
| name. Using string functions, if the folder name matches the criteria, I
| write out a messages stating the folder name as the version of .Net that
is
| installed.
|
| Can anyone assist me with this, or point me to a good code sample?
|
| TIA,
|
| DetRich